A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Excel » Worksheet Functions
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Macro repeat



 
 
Thread Tools Display Modes
  #1  
Old May 21st, 2009, 11:37 PM posted to microsoft.public.excel.worksheet.functions
decimal
external usenet poster
 
Posts: 3
Default Macro repeat

How do you make a macro repeat over and over until you tell it to stop. In
lotus you could make it loop back on itself until you hit ctrl somehting to
interupt it. I have 3000 lines in groups of 10, doing something to each of
the 10, then the same thing to the next 10. Since a macro always starts in
its original cell(a bug?), I need to just keep moving down, like I had it
learn to move down 10 times. In this case I would have it move the 11th, and
repeat itself. I don't know how to do that...
-Decimal
  #2  
Old May 21st, 2009, 11:47 PM posted to microsoft.public.excel.worksheet.functions
Don Guillett
external usenet poster
 
Posts: 6,167
Default Macro repeat

Not exaclty sure what you want but test this to see if if helps.

Sub doovereach10()
lr = Cells(Rows.Count, "k").End(xlUp).Row
For i = 1 To lr Step 10
For j = 1 To 10
Cells(i, "k").Offset(j) = i
Next j
Next i
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"decimal" wrote in message
...
How do you make a macro repeat over and over until you tell it to stop.
In
lotus you could make it loop back on itself until you hit ctrl somehting
to
interupt it. I have 3000 lines in groups of 10, doing something to each
of
the 10, then the same thing to the next 10. Since a macro always starts
in
its original cell(a bug?), I need to just keep moving down, like I had it
learn to move down 10 times. In this case I would have it move the 11th,
and
repeat itself. I don't know how to do that...
-Decimal


  #3  
Old May 21st, 2009, 11:53 PM posted to microsoft.public.excel.worksheet.functions
Sheeloo
external usenet poster
 
Posts: 797
Default Macro repeat

In VBA you can use FOR loop or DO WHILE loop
see http://www.angelfire.com/biz7/julian...ans_macros.htm
An example:

Sub example()
for i = 1 to 3000 Step 10
for j = 1 to 10
' Do what you want to cell referenced by using i and j
' You can call a macro too by writing its name
Next j
Next i
End Sub

"decimal" wrote:

How do you make a macro repeat over and over until you tell it to stop. In
lotus you could make it loop back on itself until you hit ctrl somehting to
interupt it. I have 3000 lines in groups of 10, doing something to each of
the 10, then the same thing to the next 10. Since a macro always starts in
its original cell(a bug?), I need to just keep moving down, like I had it
learn to move down 10 times. In this case I would have it move the 11th, and
repeat itself. I don't know how to do that...
-Decimal

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 07:36 PM.


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