ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to automate a macro to run on all sheets in a workbook (https://www.excelbanter.com/excel-programming/291614-how-automate-macro-run-all-sheets-workbook.html)

Maurice Roche

How to automate a macro to run on all sheets in a workbook
 
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

Chip Pearson

How to automate a macro to run on all sheets in a workbook
 
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


"Maurice Roche" wrote in
message ...
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




Tom Ogilvy

How to automate a macro to run on all sheets in a workbook
 
Dim sh as Worksheet
for each sh in ActiveWorkbook.worksheets
sh.Activate

Next

--
Regards,
Tom Ogilvy

"Maurice Roche" wrote in message
...
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





All times are GMT +1. The time now is 01:18 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com