Link to home
Start Free TrialLog in
Avatar of Sheldon Livingston
Sheldon LivingstonFlag for United States of America

asked on

Excel worksheet name

In VBA you can name a worksheet through its properties window.  

This is not the same name that is displayed on a tab.  This method is an attempt to keep the sheet name constant so that if a user renames a sheet, you can still control it.

My problem is that I need to determine which sheet I am on using that same VBA name property.
Avatar of zorvek (Kevin Jones)
zorvek (Kevin Jones)
Flag of United States of America image

Then name them the same. I name my sheets like this:

Tab Name: My Sheet
VBA Name: wksMySheet

Kevin
Do you want

Activesheet.name
make the first row(1) and column(A) hidden and put some secret text in cell A1. (or any other cell of your choice.)

In the VBA script loop through all the sheets and where every you find the secret key in cell A1 rename the sheet to the desired name.
Can you be more explicit about what your question is? What are you trying to do?

Kevin
ASKER CERTIFIED SOLUTION
Avatar of Saqib Husain
Saqib Husain
Flag of Pakistan image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Sheldon Livingston

ASKER

Kevin... let's say I name them the same and the user changes the name?

ssaqibh:  ActiveSheet.name gives you the name on the tab.

viralypatel:  Trying not to resort to that kind of a work around.

So, the first sheet tab and show Sheet1 and the second one can show Sheet2.  You can change, from Atl + F11, the name "propertiy" of the sheets to wksFirst and wksSecond.  Now the user changs the tabs to read Sheet A and Sheet B.  From VBA how do I know if the active sheet is wksSecond, Sheet B or Sheet2?
ssaqibh:  !!!!

Thanks  

codename is it.
Perfect!