Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Macro - general refence required 1

Status
Not open for further replies.

mart10

MIS
Nov 2, 2007
394
GB
I am using Excel 2003 I have a macro 1 (MacroShiftData1Day) which shifts lots of data.Occasionally I want to do the shist 3 times so just run the macro 3 times using:

Sub MacroShiftData3Days()' MacroShiftData3Days Macro'1st Pass Application.Run "'Balance & Cash Flow Forecasts 1.xls'!MacroShiftData1Day"'2nd Pass
Application.Run "'Balance & Cash Flow Forecasts 1.xls'!MacroShiftData1Day"'3rd Pass
Application.Run "'Balance & Cash Flow Forecasts 1.xls'!MacroShiftData1Day"
End Sub

However this obviously references the macro1 in this workbook name and it needs to be general as I am just setting this up as a template at moment and will have lots of differetly named copies. What syntax do I need to do this?
 
However this obviously references the macro1 in this workbook name ...

If the macro is in the same workbook, just do:
Code:
Sub MacroShiftData3Days()
   ' MacroShiftData3Days Macro
     '1st Pass   
     MacroShiftData1Day       
     '2nd Pass   
     MacroShiftData1Day         
     '3rd Pass   
     MacroShiftData1Day       
End Sub
... or am I missing something here?



Cheers, Glenn.

Beauty is in the eye of the beerholder.
 
That's great!

Actually, you can make it shorter:

Code:
Sub MacroShiftData3Days()
   ' MacroShiftData3Days Macro
     For mypass = 1 to 3
        MacroShiftData1Day       
     Next
End Sub


Cheers, Glenn.

Beauty is in the eye of the beerholder.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top