Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find the index number of renamed sheets in excel-vba

Tags:

excel

vba

I have about 8 sheets in a workbook with different names. Is there a way using VBA to activate one ore more of these sheets based on their index number? For example I have sheets named, "Month", "Name", "Age" etc... how can I find their index number?

like image 773
terence vaughn Avatar asked Nov 04 '13 19:11

terence vaughn


1 Answers

Try this

Sheets("<sheet Name>").Index

If you want to get code name

Sheets("<sheet Name>").codename

It’s possible for the sheet name to be different from the code name. When you create a sheet, the sheet name and code name are the same, but changing the sheet name doesn’t change the code name, and changing the code name (using the Properties window in the Visual Basic Editor) doesn’t change the sheet name.

like image 67
Santosh Avatar answered Oct 11 '22 19:10

Santosh