Count

  • Thread starter Thread starter Guest
  • Start date Start date
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.
 
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
 
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
 
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
 
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




.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top