Count

G

Guest

Hello,

I would like to make my macro perform an operation every
25th and 10th time it passes through a Do Loop and/or a
For Next Loop.

I am familiar with setting the variable to 0 before the
loop then + 1 everytime through, but how can I have it do
something else every 10th time through.
 
J

JE McGimpsey

One way:

Dim i As Long
For i = 0 to 100
If (i = 10) or (i = 25) Then
'Do special stuff
End If
'Do normal stuff
Next i
 
G

Guest

Thanks,

but what about the next 10 or 25, when the count gets to
20 and 30 and 40 or 50 and 75 and 100

Thanks
 
J

JE McGimpsey

I didn't interpret your requirements that way. Here's one way:

Dim i As Long
For i = 1 to 100
If (i Mod 10 = 0) or (i Mod 25 = 0) Then
'Do special stuff
End If
'Do normal stuff
Next i
 
G

Guest

Thank You





-----Original Message-----
I didn't interpret your requirements that way. Here's one way:

Dim i As Long
For i = 1 to 100
If (i Mod 10 = 0) or (i Mod 25 = 0) Then
'Do special stuff
End If
'Do normal stuff
Next i




.
 
Top