ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Selecting Invisible worksheets (https://www.excelbanter.com/excel-programming/352020-selecting-invisible-worksheets.html)

Ken Soenen

Selecting Invisible worksheets
 
Is there a way to keep a worksheet invisible yet be able to select it in the
code. I know I can set and use the cells on an invisible sheet, but it
doesn't appear that I can SELECT it [sheets("ratsafrats").select or
sheet4.select]. I have a number of sheets that will just be an annoyance to
the user but they are needed by the code(such as templates, database,...).

Any thoughts would be appreciated.

ken



Norman Jones

Selecting Invisible worksheets
 
Hi Ken,

A hidden sheet cannot be selected.

However, selections are rarely necessary or desirable. Most sheet
manipulation can be effected without unhiding or selecting the sheet.

If you experience any problem in rewriting your code to remove unnecessary
selections, post back with the relevant code.


---
Regards,
Norman



"Ken Soenen" wrote in message
...
Is there a way to keep a worksheet invisible yet be able to select it in
the code. I know I can set and use the cells on an invisible sheet, but it
doesn't appear that I can SELECT it [sheets("ratsafrats").select or
sheet4.select]. I have a number of sheets that will just be an annoyance
to the user but they are needed by the code(such as templates,
database,...).

Any thoughts would be appreciated.

ken




JMB

Selecting Invisible worksheets
 
It's uncommon to have to select or activate a sheet to work with it, so most
of the actions performed with a sheet can be done regardless of whether or
not it's hidden (although I've never figured out how to print a hidden sheet
without unhiding it first).

If you have to have the sheet unhidden, you could change the visible
property at the beginning and end of your code.

Worksheets("Sheet1").Visible = xlsheetvisible
your code
Worksheets("Sheet1").Visible = xlsheethidden

or you can assign the visible property value to a variable, make the sheet
visible, work with the sheet, then set the visible property equal to the
variable. This way the visible status of the sheet is just whatever it was
before your code executed.

VisibleState = Worksheets("Sheet1").Visible
Worksheets("Sheet1").Visible = xlsheetvisible
your code
Worksheets("Sheet1").Visible = VisibleState

"Ken Soenen" wrote:

Is there a way to keep a worksheet invisible yet be able to select it in the
code. I know I can set and use the cells on an invisible sheet, but it
doesn't appear that I can SELECT it [sheets("ratsafrats").select or
sheet4.select]. I have a number of sheets that will just be an annoyance to
the user but they are needed by the code(such as templates, database,...).

Any thoughts would be appreciated.

ken





All times are GMT +1. The time now is 04:20 PM.

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