PC Review


Reply
Thread Tools Rate Thread

Alternate way to refer to sheets???

 
 
Robert Crandal
Guest
Posts: n/a
 
      30th Nov 2009
My VBA code always assumes that the names of my sheets
will never change. However, if a user changes the name
of "Sheet1" to something else (such as "mysheet", for example),
then my VBA will not be able to find the sheet formerly
known as "Sheet1".

Is there a solution to this problem?? Is there an alternate
way to refer to a sheet other than by the label name on the
tab??

thankx


 
Reply With Quote
 
 
 
 
marcus
Guest
Posts: n/a
 
      30th Nov 2009
Hi Robert

Each sheet will have a number assigned to it. Sheet1 will be 1
sheet2, is 2 no matter what you call sheet2.

Worksheets(2).Activate

The above will activate the sheet no matter what the name of "Sheet2"
becomes.

Take care

Marcus
 
Reply With Quote
 
Per Jessen
Guest
Posts: n/a
 
      30th Nov 2009
Using worksheet index numbers is not a good solution, as user can change the
the order of the sheets or insert new sheets.

Worksheets(2) will always refer to the worksheet placed as second Tab.

You can protect the workbook to prevent user from renaming and inserting new
sheets, if user do not need theese options, or you can use the VBA level
sheet names.

In the project explorer you see two sheet names for each sheet. The first is
the VBA level name which do not change if user change the workbook level
name (tab name).

Use the VBA level sheet name like this:

Sheet2.Activate

Hopes this helps.
....
Per

"marcus" <(E-Mail Removed)> skrev i meddelelsen
news:e25b43c8-a8a6-48c4-97fb-(E-Mail Removed)...
> Hi Robert
>
> Each sheet will have a number assigned to it. Sheet1 will be 1
> sheet2, is 2 no matter what you call sheet2.
>
> Worksheets(2).Activate
>
> The above will activate the sheet no matter what the name of "Sheet2"
> becomes.
>
> Take care
>
> Marcus


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Refer to sheets without using tab name?? Robert Crandal Microsoft Excel Programming 4 28th Dec 2009 12:20 AM
Hyperlink Alternate Sheets Dolphinv4 Microsoft Excel Misc 3 13th Dec 2007 01:49 AM
find out which sheets refer to a cel =?Utf-8?B?SXZhbm8=?= Microsoft Excel Worksheet Functions 1 24th Apr 2007 06:26 PM
refer to sequential sheets in a formula =?Utf-8?B?c2Vhbm9uaWFsbGFpbg==?= Microsoft Excel Worksheet Functions 3 30th Jan 2007 11:25 PM
refer to the sheets Name property in my code (not what is on the Tab) =?Utf-8?B?U2FuZHk=?= Microsoft Excel Programming 3 29th Jan 2004 08:45 PM


Features
 

Advertising
 

Newsgroups
 


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