Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Worksheet name in Macro

How can I make it so that the worksheet names references in a macro wil
change as I change the worksheet name?

Thanks
Ca

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 320
Default Worksheet name in Macro

Use the Set statement:
Set CurrSheet = ActiveSheet (or set CurrSheet = Sheets("HERMAN")
Then you can use
CurrSheet.Name = "WAMMER"
and still refer to Currsheet instead of Sheets("Herman") or Sheets("WAMMER")
eg: CurrSheet.Range("G5").Value = 22
will change the G5 to 22 no matter what its name is.

"wammer " wrote:

How can I make it so that the worksheet names references in a macro will
change as I change the worksheet name?

Thanks
Cam


---
Message posted from http://www.ExcelForum.com/


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Worksheet name in Macro

Thanks Bob -

It definitely works. Does this still mean that I need to go change th
Set CurrSheet within the macro every time I change the name? It ther
no way to make it change automatically?

Thanks
Cam


Bob Umlas, Excel MVP wrote:
*Use the Set statement:
Set CurrSheet = ActiveSheet (or set CurrSheet = Sheets("HERMAN")
Then you can use
CurrSheet.Name = "WAMMER"
and still refer to Currsheet instead of Sheets("Herman") o
Sheets("WAMMER")
eg: CurrSheet.Range("G5").Value = 22
will change the G5 to 22 no matter what its name is.

"wammer " wrote:

How can I make it so that the worksheet names references in a macr

will
change as I change the worksheet name?

Thanks
Cam


---
Message posted from http://www.ExcelForum.com/



--
Message posted from http://www.ExcelForum.com

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 135
Default Worksheet name in Macro

wammer, you could also reference the worksheet name in VBA and not the
worksheet tab name, here if you change the tab name of sheet 2 the first
Macro will not work the second one will

Sheet tab name
Sheets("sheet2").Range("A3") = "25"

VBA sheet name
Sheet2.Range("A3") = "25"


--
Paul B
Always backup your data before trying something new
Please post any response to the newsgroups so others can benefit from it
Feedback on answers is always appreciated!
Using Excel 2000 & 97
** remove news from my email address to reply by email **
"wammer " wrote in message
...
Thanks Bob -

It definitely works. Does this still mean that I need to go change the
Set CurrSheet within the macro every time I change the name? It there
no way to make it change automatically?

Thanks
Cam


Bob Umlas, Excel MVP wrote:
*Use the Set statement:
Set CurrSheet = ActiveSheet (or set CurrSheet = Sheets("HERMAN")
Then you can use
CurrSheet.Name = "WAMMER"
and still refer to Currsheet instead of Sheets("Herman") or
Sheets("WAMMER")
eg: CurrSheet.Range("G5").Value = 22
will change the G5 to 22 no matter what its name is.

"wammer " wrote:

How can I make it so that the worksheet names references in a macro

will
change as I change the worksheet name?

Thanks
Cam


---
Message posted from http://www.ExcelForum.com/

*



---
Message posted from http://www.ExcelForum.com/



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
Excel Macro Issue Trying to autorun Macro Upon Opening Worksheet wyndman Excel Programming 2 May 25th 04 06:59 PM
How to end macro on inital active worksheet containing macro button that was clicked Silverhawk1 Excel Programming 2 May 14th 04 03:58 PM
How? Macro to copy range to new worksheet, name new worksheet, loop Repoman Excel Programming 9 October 9th 03 01:45 PM
macro to apply worksheet event to active worksheet Paul Simon[_2_] Excel Programming 3 August 7th 03 02:50 AM
Record Worksheet Content as Macro and Execute from another Worksheet David McRitchie[_2_] Excel Programming 2 July 23rd 03 09:43 AM


All times are GMT +1. The time now is 12:46 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"