#1   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default 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.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default 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.

  #3   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default 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.

.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default 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

  #5   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default 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

.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Count Employee Work Time - Don't Count Duplicates J Excel Worksheet Functions 3 May 1st 07 10:47 PM
Count Employee Work Time - Don't Double-count Overlapping Apts. J Excel Worksheet Functions 0 April 27th 07 05:52 AM
Excel 2000, count, sort a list & count totals? sunslight Excel Worksheet Functions 1 April 9th 07 05:46 PM
How do i count numbers and letters to find a total count of all Linda Excel Worksheet Functions 4 November 10th 05 04:51 PM
Count Intervals of Filtered TEXT values in Column and Return Count across a Row Sam via OfficeKB.com Excel Worksheet Functions 9 July 31st 05 03:37 AM


All times are GMT +1. The time now is 11:49 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"