For, Next, Loop vs. Select / Case Is
On Jun 16, 11:27*am, GS wrote:
To add to Dom's input, you might want to use a Select Case structure so
the code is easier to understand...
Sub MyValueOffset_2()
* Dim i As Integer
* For i = 6 To 250
* * Do While Cells(i, 14).Value 0
* * * Select Case Cells(i, 14).Value
* * * * Case = 20: Cells(i, 14).Offset(0, 21).Value = 1
* * * * Case 9 To 12: Cells(i, 14).Offset(0, 21).Value = 2
* * * * Case 7, 8: Cells(i, 14).Offset(0, 21).Value = 3
* * * * Case < 5: Cells(i, 14).Offset(0, 21).Value = 4
* * * End Select 'Cells(i, 14).Value
* * Loop 'While Cells(i, 14).Value 0
* Next
End Sub
--
Garry
Free usenet access athttp://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc
Garry, you put the DO WHILE loop within the FOR LOOP. You'll never
get out of it.
|