Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 25
Default macro sheet name conflicts

I have a hundred workbooks, each with ten sheets. The sheets are identical in
structure and I want to create a macro that will run on each sheet of each
workbook. The problem comes with the fact that the worksheets aren't
consistently named across workbooks and so any sheet name references won't
work. My work around has been to write a general macro that will run on one
sheet and then select the sheets one by one and run it on each. I open each
workbook and run it sheet by sheet, which is time consuming. I'm wondering if
it's at all possible to create a macro that will run on all sheets in a
workbook regardless of their names.

Thanks for any help.

spence
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2,202
Default macro sheet name conflicts

I have a hundred workbooks, each with ten sheets. The sheets are identical
in
structure and I want to create a macro that will run on each sheet of each
workbook. The problem comes with the fact that the worksheets aren't
consistently named across workbooks and so any sheet name references won't
work. My work around has been to write a general macro that will run on
one
sheet and then select the sheets one by one and run it on each. I open
each
workbook and run it sheet by sheet, which is time consuming. I'm wondering
if
it's at all possible to create a macro that will run on all sheets in a
workbook regardless of their names.


You should be able to use this structure to run your code on each worksheet
in within the workbook your code is in...

Dim WS As Worksheet
For Each WS In Worksheets
'
' Your code goes here... reference current sheet being processed by WS
'
Next

Here is a quick example using this structure...

Dim Msg As String
Dim WS As Worksheet
For Each WS In Worksheets
Msg = Msg & WS.Name & vbCrLf
Next
MsgBox Msg

This will display all worksheet names from the workbook in a MessageBox.

Rick

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
Save conflicts Donna A Excel Discussion (Misc queries) 0 June 27th 06 02:21 AM
Sheet protection code conflicts with Pivot Table "auto refresh" KG Excel Discussion (Misc queries) 6 December 21st 05 11:16 PM
Excel Option Conflicts JB2005 Excel Discussion (Misc queries) 1 August 5th 05 01:07 PM
Excel Option Conflicts JB2005 Excel Discussion (Misc queries) 0 August 4th 05 09:28 PM


All times are GMT +1. The time now is 12:08 PM.

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"