Originally Posted by
Nader
What a bout While..Wend .
"While...wend" is essentially the same as "Do While condition [statements] Loop". For your example it would be:
[VBA]
RowCount = 1
While Cells(RowCount, 1).Value <> 5
RowCount = RowCount + 1
Wend
Cells(RowCount, 1) = 10
[/VBA]
But the "Do While...Loop" method is more useful in some situations because you can use "Exit Do" to jump out of the loop. For example, if you only want to look down 100 rows for the number 5 (in your example) you would have this:
[VBA]RowCount = 1
Do While Cells(RowCount, 1).Value <> 5
RowCount = RowCount + 1
If RowCount > 100 Then Exit Do
Loop
Cells(RowCount, 1) = 10
[/VBA]
"While....Wend" doesn't have an Exit statement.