ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Get name of active sheet (https://www.excelbanter.com/excel-programming/436955-get-name-active-sheet.html)

Robert Crandal

Get name of active sheet
 
I have one sheet in my workbook named "Work Data".
If this sheet is active, then the following expression

Application.ActiveSheet.Name

.... will return a string of "Work Data". However, I don't
want the name of the string in the sheet tab, I want the name from
my VBA project window (named Sheet1). How can I retrieve
the VBA name of my sheet??

thank u


Peter T

Get name of active sheet
 
Application.ActiveSheet.CodeName

Be aware though that newly added sheets since the workbook was opened while
the VBE is closed will not have a codeName. There are various workarounds to
force one, search this ng.

Regards,
Peter T

"Robert Crandal" wrote in message
...
I have one sheet in my workbook named "Work Data".
If this sheet is active, then the following expression

Application.ActiveSheet.Name

... will return a string of "Work Data". However, I don't
want the name of the string in the sheet tab, I want the name from
my VBA project window (named Sheet1). How can I retrieve
the VBA name of my sheet??

thank u




Mike H

Get name of active sheet
 
Hi,

MsgBox ActiveSheet.CodeName

Mike

"Robert Crandal" wrote:

I have one sheet in my workbook named "Work Data".
If this sheet is active, then the following expression

Application.ActiveSheet.Name

.... will return a string of "Work Data". However, I don't
want the name of the string in the sheet tab, I want the name from
my VBA project window (named Sheet1). How can I retrieve
the VBA name of my sheet??

thank u

.



All times are GMT +1. The time now is 11:59 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com