How to automate a macro to run on all sheets in a workbook

  • Thread starter Thread starter Maurice Roche
  • Start date Start date
M

Maurice Roche

Hello,

I know that this is probably really simple, but I am
trying the run a macro on all sheets in a workbook, there
are 60 sheets all of the same format and structure,
however i have to rearrange the structure, so I was hoping
that I can record a macro and then add some code so it
will run on all sheets?

Any help would be appreciated

Thanks

Maurice
 
Maurice,

Try structuring your code as the following:

Dim WS As Worksheet
For Each WS In Worksheets
' do something with WS
Next WS


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
 
Dim sh as Worksheet
for each sh in ActiveWorkbook.worksheets
sh.Activate

Next
 

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