Running Macro/VBA in multiple worksheets.
For Each sh In ActiveWorkbook.Worksheets
Call MyMacro
Next sh
You might need to pass the sh object to the macro so that it can work on
that, like this
For Each sh In ActiveWorkbook.Worksheets
Call MyMacro(sh)
Next sh
Sub MyMacro(pSheet as worksheet)
With pSheet
'...
End With
End Sub
--
HTH
Bob Phillips
(remove nothere from email address if mailing direct)
"YellowBird" wrote in message
...
I am trying to run a Macro (which works perfectly) in "All" Worksheets of
a
particular Workbook. I currently have seven Worksheets in the Workbook
and
have to select each Worksheet and manually run the Macro. I will
eventually
have 50 (maybe more) Worksheets where the Macro will need to be run. I
have
used the "Private Sub" code in VBA but can only get it to execute the
Macro
in the active Worksheet when the Workbook opens.
Is there code that could/would run the Macro in "All" the Sheets? Sheet1,
Sheet2, Sheet3, Sheet4.
Any help would be greatly appreciated.
--
SHD
|