run all worksheet macros
On Aug 13, 3:54 pm, "Trevor Shuttleworth"
wrote:
One way, but a little tedious:
Sub CallSheetMacros()
' assumes macro is called Macro1 in each sheet
Sheet1.Macro1
Sheet2.Macro1
Sheet3.Macro1
:
:
Sheet3.Macro1
End Sub
Sub test()
' more scalable ... still assumes macro is called Macro1 in each sheet
For Each sht In Sheets
On Error Resume Next
sht.Macro1
On Error GoTo 0
Next
End Sub
Regards
Trevor
"Old Fossil Bama" wrote in oglegroups.com...
I have a workbook with 35 worksheets, each with a different macro.
How can I create a workbook level macro torunthe specific macro tied
to each of the 35 worksheets?
Thanks.
I have checked out some previous postings, but theyallseem to apply
a single macro against multiple sheets, but I need to launch a macro
tied to each of 35 sheets.- Hide quoted text -
- Show quoted text -
Thanks, Trevor.
Tried the code like so:
Sub CallSheetMacros()
Sheet1.main
Sheet2.main
Sheet3.main
.........etc
End Sub
The problem is that as each macro was called, the open worksheet focus
remained on Sheet1, resulting in all the succeeding macros being run
against it instead of the corresponding worksheet.
How can I shift focus to the correct sheet each time before the macro
runs?
Something like this:
set focus to Sheet 1
Sheet1.main
set focus to Sheet 2
Sheet2.main
set focus to Sheet 3
Sheet3.main
etc.....
Thanks again.
|