ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Excel Sheets (https://www.excelbanter.com/excel-discussion-misc-queries/83282-excel-sheets.html)

lbargers

Excel Sheets
 

Hello,

how can I reference the name of the currently selected sheet, in a
macro?

I tried:

me.name

and it only pulls up the name of the first sheet, no matter which sheet
I have selected..

Thanks for any help on this issue..

Larry


--
lbargers
------------------------------------------------------------------------
lbargers's Profile: http://www.excelforum.com/member.php...o&userid=32798
View this thread: http://www.excelforum.com/showthread...hreadid=532978


Dave Peterson

Excel Sheets
 
If the code is under a worksheet, then me.name will give you the name of the
sheet that owns the code.

You may want: Activesheet.name



lbargers wrote:

Hello,

how can I reference the name of the currently selected sheet, in a
macro?

I tried:

me.name

and it only pulls up the name of the first sheet, no matter which sheet
I have selected..

Thanks for any help on this issue..

Larry

--
lbargers
------------------------------------------------------------------------
lbargers's Profile: http://www.excelforum.com/member.php...o&userid=32798
View this thread: http://www.excelforum.com/showthread...hreadid=532978


--

Dave Peterson

lbargers

Excel Sheets
 

Hey Dave,

I should of explained myself better, I would like the code in a Module,
this way the user will not have to select between multiple macros. The
user should be able to select any sheet in the workbook and exectue the
macro..

Thanks

Larry


--
lbargers
------------------------------------------------------------------------
lbargers's Profile: http://www.excelforum.com/member.php...o&userid=32798
View this thread: http://www.excelforum.com/showthread...hreadid=532978


Dave Peterson

Excel Sheets
 
Have the user select the correct sheet first.

Then you can write your macro to work against the Activesheet.

With Activesheet
.range("a1").clearcontents
end with

For example.



lbargers wrote:

Hey Dave,

I should of explained myself better, I would like the code in a Module,
this way the user will not have to select between multiple macros. The
user should be able to select any sheet in the workbook and exectue the
macro..

Thanks

Larry

--
lbargers
------------------------------------------------------------------------
lbargers's Profile: http://www.excelforum.com/member.php...o&userid=32798
View this thread: http://www.excelforum.com/showthread...hreadid=532978


--

Dave Peterson


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

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