choubix
06-27-2008, 02:53 AM
hello,
I have a range in column E
it start at row 2 and can go down to the bottom of the page (no gap in the data set)
the values in this range can be: 0, 1 or 2.
I need to loop in this range.
If the 1st value is 0: i need to exit the loop
if the value is 1: I loop again
if the value is 2: I exit the loop
in 3 others cells I wirte how many occurence of 0,1 and 2 I had when looping in the range.
I currently have written this code but the loop is not correct:
k = 1
For Each l In wsOutput.Cells(Rows.Count, "E").End(xlUp)
If wsOutput.Cells(k + 1, 5) = 0 Then 'on est converti en actions
wsOutput.Cells(2, 14) = wsOutput.Cells(2, 14) + 1
Exit For
ElseIf wsOutput.Cells(k + 1, 5) = 1 Then 'on touche le coupon
wsOutput.Cells(3, 14) = wsOutput.Cells(3, 14) + 1
ElseIf wsOutput.Cells(k + 1, 5) = 2 Then 'la structure est callee
wsOutput.Cells(4, 14) = wsOutput.Cells(4, 14) + 1
Exit For
End If
k = k + 1
Next l
does anyone have an idea of what wrong please?
thx
I have a range in column E
it start at row 2 and can go down to the bottom of the page (no gap in the data set)
the values in this range can be: 0, 1 or 2.
I need to loop in this range.
If the 1st value is 0: i need to exit the loop
if the value is 1: I loop again
if the value is 2: I exit the loop
in 3 others cells I wirte how many occurence of 0,1 and 2 I had when looping in the range.
I currently have written this code but the loop is not correct:
k = 1
For Each l In wsOutput.Cells(Rows.Count, "E").End(xlUp)
If wsOutput.Cells(k + 1, 5) = 0 Then 'on est converti en actions
wsOutput.Cells(2, 14) = wsOutput.Cells(2, 14) + 1
Exit For
ElseIf wsOutput.Cells(k + 1, 5) = 1 Then 'on touche le coupon
wsOutput.Cells(3, 14) = wsOutput.Cells(3, 14) + 1
ElseIf wsOutput.Cells(k + 1, 5) = 2 Then 'la structure est callee
wsOutput.Cells(4, 14) = wsOutput.Cells(4, 14) + 1
Exit For
End If
k = k + 1
Next l
does anyone have an idea of what wrong please?
thx