hiding sheets and sheet visibility

cocopops2001

Board Regular
Joined
Apr 18, 2011
Messages
112
is there anyway i can have pages that are 'hidden' but still allows the user to select them i am currently using a button? the
Code:
sheets(x).select
does not work when the sheets are hidden. not xlveryhidden just xlhidden.

i have also tried
Code:
 sheets(x).activate
to no avail. it goes to the next sheet in the line, ie when i want sheet 5 it goes to sheet 6.

any ideas?
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
"is there anyway i can have pages that are 'hidden' but still allows the user to select"

If the user can select the sheets, how can they be called hidden?
 
Upvote 0
the workbook is essentially a database of pages in which the user can navigate through using buttons with macros assigned, i would loike the pages to be hidden so that there is not a long list of tabs along the bottom. so i will need to put in something like
Code:
Sub pipes_menu()
sheet(5).visible = xlvisible    
Sheets(5).select
End Sub

how do i make sure they hide again when the user navigates to a different page would something like

Code:
dim sheetnum as worksheet.index

set sheetnum as activesheet.index

sheet(sheetnum).visible = xlhidden
on each button work?

as long as it is before the unhide and select commands so that it is the previous page that is hidden?

what do you think?
 
Upvote 0
Perhaps if you put this in the ThisWorkbook code module.
Code:
Private Sub Workbook_SheetActivate(ByVal Sh As Object)
    Dim oneSheet As Worksheet
    
    For Each oneSheet In ThisWorkbook.Worksheets
        oneSheet.Visible = IIf(1 < Abs(oneSheet.Index - Sh.Index), xlSheetHidden, xlSheetVisible)
    Next oneSheet
End Sub
 
Upvote 0
is this basically testing if the sheet is being selected then checking its visibility settings and making it visible if it is not?

I have seen it somewhere before but what are the integers for visibility

1 xlvisible

0 xlhidden

-1 xlveryhidden
 
Upvote 0
Try running this

Code:
Sub list()
MsgBox xlSheetVeryHidden & vbNewLine & xlSheetHidden & vbNewLine & xlSheetVisible
End Sub
 
Upvote 0
very good VoG, you obviously know your stuff. tried the code mike and sort of does what i want but not quite. this cycles through the sheets when really I want two sheets to be visible at all times and any other sheet visible only when it is selected.

ps i also have one sheet that is to stay xlveryhidden at all times. thanks
 
Last edited:
Upvote 0
I've just don't something similar. I've just created macros to view sheets and macros to hide all and unhide all.
In module
Write:
Sub ViewSheet1()
Sheets("Sheet1").Visible = True
Sheets("Sheets1").Activate
End Sub

You can assign this to a obeject or button and this will transport the user to the sheet1 and unhide it.

To hide sheet just simply change = false to True

Maybe u can adapt this to ur situation
If u want certain sheets to stay visible stay leave them out of macro.

Hope this helps. :)
 
Upvote 0

Forum statistics

Threads
1,224,590
Messages
6,179,753
Members
452,940
Latest member
rootytrip

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top