Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
jstoner50
 
Posts: n/a
Default Worksheet tabs in a Macro


I have a macro that references the sheet tab name that I have given it.
The problem is these Tab names change periodically, And that means I
have to run a find and replace function to change my Macro with these
tab names with the new names. When I look at the module in the Macro
screen they show sheet1=(my Name). But what i need is to reference my
macro to the Excel default name sheet1, sheet2, sheet3,...etc. I hope
I explained my issue.

Thanks for any help


--
jstoner50
------------------------------------------------------------------------
jstoner50's Profile: http://www.excelforum.com/member.php...o&userid=28651
View this thread: http://www.excelforum.com/showthread...hreadid=483154

  #3   Report Post  
John Michl
 
Posts: n/a
Default Worksheet tabs in a Macro

Have you considered using the sheet index instead of the name? Sheet1
is always an index of 1 even though the name changes. I'd probably DIM
the sheets at the beginning of the code. For instance, assume Sheet1
was renamed to "Info", Sheet2 to "Data" and Sheet3 "Results". Then....

Sub SheetNames()
Dim shInfo, shData, shResults As Worksheet

Set shInfo = Sheets(1)
Set shData = Sheets(2)
Set shResults = Sheets(3)

i = 1
For Each sh In Sheets
MsgBox Sheets(i).Name
i = i + 1
Next
End Sub


HTH - John
www.JohnMichl.com

  #4   Report Post  
jstoner50
 
Posts: n/a
Default Worksheet tabs in a Macro


The problem is that Excel looks at the name of the tab you have given
it. I'm trying to use Excels default name when you first start out
Excel creates a sheet1 once you have changed the name Excel does not
recognize sheet1 again. I hope this clears up the confusion.

Jim


--
jstoner50
------------------------------------------------------------------------
jstoner50's Profile: http://www.excelforum.com/member.php...o&userid=28651
View this thread: http://www.excelforum.com/showthread...hreadid=483154

  #5   Report Post  
John Michl
 
Posts: n/a
Default Worksheet tabs in a Macro

Jim, my method uses the index for the sheet which you cannot change.
Sheet1 always has an index of 1 even when you change the name to
something other than Sheet1.

- John

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
Hierarchical Worksheet Tabs??? New Excel feature? JMcC Excel Discussion (Misc queries) 1 October 11th 05 04:46 PM
Keep Format After Merging Worksheets Using CopyFromWorksheet Macro Mark Jackson Excel Discussion (Misc queries) 0 September 25th 05 10:59 PM
Excel should let me format worksheet tabs in multiple rows. Fawzi_Masri Excel Worksheet Functions 1 September 19th 05 06:23 PM
macro to copy and edit then delete a worksheet lschuh Excel Discussion (Misc queries) 13 July 27th 05 09:02 PM
macro help thephoenix12 Excel Discussion (Misc queries) 4 July 15th 05 05:57 PM


All times are GMT +1. The time now is 06:01 PM.

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

About Us

"It's about Microsoft Excel"