LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default looping excel macros


Brad;602306 Wrote:
I have Excel 2002 and routinely use the macro recorder. I can read the
macros and make simple edits, but never learned to program in VB and
my
fortran programming experience is from 30 years ago. After recording
a
macro, I want it to loop 15 times before exiting. What lines to I need
to
add to the code to start and end the loop? I already have the macro.
It
basically inserts a line, totals certain columns and formats one cell.

Brad


Code:
--------------------
For i = 1 to 15
'your repeating code here (or a call to your macro)
Next i
--------------------

You can use i within your code, so the first line could be say:
For i = 16 to 30
or
For i = 10 to 50 step 3
or
For i = 20 to 5 step -1
etc. etc.
There are other loops:

Code:
--------------------
Do
'... your code including altering value of j here
loop until j 23
--------------------


or

Code:
--------------------
Do while j <15
'... your code including altering value of j here
Loop
--------------------


press f1 when your text cursor is sitting on the word 'do' in the vb
editor (or on the word 'for').


--
p45cal

*p45cal*
------------------------------------------------------------------------
p45cal's Profile: 558
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=166946

Microsoft Office Help

 
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
Help with Looping Macros Chaitanya Excel Worksheet Functions 0 December 24th 10 06:01 AM
Looping Macros that change Dar Excel Discussion (Misc queries) 1 February 25th 10 10:09 PM
looping macros Bradly Excel Programming 3 August 10th 09 09:29 PM
Help needed - seriously (looping? macros? formulas?) jarski Excel Programming 4 June 29th 05 05:44 PM
Looping macros using VB code accessuser1308 Excel Discussion (Misc queries) 2 March 9th 05 11:11 PM


All times are GMT +1. The time now is 08:33 AM.

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

About Us

"It's about Microsoft Excel"