Run a macro on multiple worksheets?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Say I have a macro that reverses the order of a list. I have the identical
list in 5 sheets in a workbook. I tried to select all the sheets and running
the macro, but it only runs it on the worksheet I'm looking at.
 
For Each sh In Sheets(Array("Sheet1", "Sheet2",
"Sheet3","Sheet4","Sheet5"))
myMacro sh
Next sh

--
HTH

Bob Phillips

(there's no email, no snail mail, but somewhere should be gmail in my addy)
 
sh is a variable which can be left undeclared but better is to declare as
type Worksheet

Dim sh As Worksheet

myMacro is the macro that you said that you have.

--
HTH

Bob Phillips

(there's no email, no snail mail, but somewhere should be gmail in my addy)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top