ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Set Worksheet Name (https://www.excelbanter.com/excel-programming/370259-set-worksheet-name.html)

Noemi

Set Worksheet Name
 
Hi
Is it possible to set the names of each worksheet in a module so I can refer
to it within the sheets itself.

ie
Set wksCurrent = worksheets("Sheet1")
set wksKey = worksheets("Sheet2")
etc

The above is what I would like to declare and have set in a module and then
in the worksheets i would use

wksCurrent.select
wksKey.visible = true
etc.

I am hoping that I dont need to keep adding the Set wksCurrent =
Worksheets("Sheet1") etc for each private or public sub.

Bob Phillips

Set Worksheet Name
 
Declare the variables wksCurrent and wksKey as public variables before any
macros (type Worksheet), and in the first module set them as you show, and
it will remain available for all macros.

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Noemi" wrote in message
...
Hi
Is it possible to set the names of each worksheet in a module so I can

refer
to it within the sheets itself.

ie
Set wksCurrent = worksheets("Sheet1")
set wksKey = worksheets("Sheet2")
etc

The above is what I would like to declare and have set in a module and

then
in the worksheets i would use

wksCurrent.select
wksKey.visible = true
etc.

I am hoping that I dont need to keep adding the Set wksCurrent =
Worksheets("Sheet1") etc for each private or public sub.





All times are GMT +1. The time now is 03:35 PM.

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