Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default 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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to Copy Sheets to new workbook KennyD Excel Discussion (Misc queries) 18 January 31st 10 01:25 PM
Need macro to consolidate all sheets in workbook Christine[_3_] Excel Discussion (Misc queries) 1 November 14th 08 03:50 AM
Macro to create new workbook and sheets Richard Excel Discussion (Misc queries) 1 July 31st 07 07:31 PM
Use Macro to protect choosen sheets in workbook kevhatch Excel Discussion (Misc queries) 1 January 27th 07 06:52 PM
Macro to link Sheets to main workbook raven_guy Excel Discussion (Misc queries) 0 June 24th 05 12:36 PM


All times are GMT +1. The time now is 03:45 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"