|
VB-ITERATION
|
|
Source:Internet Author:Unknow Pubdate:2008-04-14
|
|
L775 (Structural)
27 Nov 04 20:04
How do I stop AN iteration when it reaches the end of a group of occupied cells filled with the IDENTICAL text (i.e. B277) in a column?
I want it to stop at the end of the list. HOW does it know that the next cell is empty so it will not error or use an empty cell. the length of the list in a column or number of rows varies for different groups that the routine or loop neet to operate on. thank you for your help. I know there is a way of doing.
L775 (Structural)
27 Nov 04 20:41
I WOULD ALSO LIKE THE SCRIPT TO TELL ME THE NUMBER OF ROWS CONTAINED IN THE GROUP.
THANKS A LOT
johnwm (Computer)
28 Nov 04 12:14
Start from the first cell and use a Do Loop, increementing the row counter and checking for the appropriate value: 字串3
CODEPrivate Sub CommandButton1_Click() a = 1 Do While ActiveSheet.Cells(a, 1) = "b277" Cells(a, 2) = a ' or do whatever you need here a = a + 1 Loop MsgBox a - 1 & " Cells affected" End Sub The example starts looking at A1 and goes down until the cell value changes. Change the initial value of a to start at a different row. The second value in the first Cells function (1 in this case) sets the column to search Good Luck johnwm ________________________________________________________ To get the best from these forums read FAQ731-376 before posting
UK steam enthusiasts: www.essexsteam.co.uk
L775 (Structural)
28 Nov 04 14:32
thanks johnwm, it worked good
PDB123 (Computer)
1 Dec 04 7:21
As fasr as i know you just put it inside a whiloe loop with a <>EOF command!
字串2
(Click:)
|
| Previous:Creating a Flowsheet GUI Next:PDA programming... |
|
[ Add TO Favorites]
[TOP] [PRINT]
[CLOCE WINDOWS] |
|
|
|