![]() |
Count
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. |
Count
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 In article , wrote: 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. |
Count
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 -----Original Message----- 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 In article , wrote: 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. . |
Count
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 In article , wrote: but what about the next 10 or 25, when the count gets to 20 and 30 and 40 or 50 and 75 and 100 |
Count
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 In article , wrote: but what about the next 10 or 25, when the count gets to 20 and 30 and 40 or 50 and 75 and 100 . |
All times are GMT +1. The time now is 02:10 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com