Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get name of an Excel worksheet containing code

Tags:

excel

vba

I have code that resides on a page and references the content of the workbook. When executed from a different worksheet, I would like to get the name of the specific Worksheet containing the code.

I have worksheets that contain data. The code is added to that worksheet and the run - which produces a Summary worksheet. From the Summary worksheet, I would like to run the code on the data worksheet. This means I can't use ActiveSheet and I would have to reference the data sheet by name.

How can I get the name of the worksheet containing the code without having to hard-code the name?

like image 791
Chris Avatar asked Aug 08 '13 15:08

Chris


1 Answers

Use the "Me" object.

Me.Name is the property you seek, wich will give you the name of the sheet containing the code regardless the active sheet.

like image 87
Sam73 Avatar answered Nov 08 '22 05:11

Sam73