hide and unhde worksheets when a set button on a form is clicked

D

Dave ferris

hi everyone,
i have a work book with 4 worksheets i have a userform that is initialised
when the workbook is opened. on the form is 4 buttons one for each sheet.
button one would show the worksheet tabs for sheets 1 and 2,
button two would show the worksheet tabs for sheets 1 and 3,
button three would show the worksheet tabs for sheet 1,
button four would show the worksheet tabs for sheets 1 and 4,

i'm taking it that by hiding the worksheet tabs that the worksheet itself is
hidden!

help in this dilema is very much appreciated.
thank you

Dave ferris
 
J

JBeaucaire

Dave said:
i have a work book with 4 worksheets i have a userform that is
initialised
when the workbook is opened. on the form is 4 buttons one for each
sheet.
button one would show the worksheet tabs for sheets 1 and 2,
button two would show the worksheet tabs for sheets 1 and 3,
button three would show the worksheet tabs for sheet 1,
button four would show the worksheet tabs for sheets 1 and 4,

i'm taking it that by hiding the worksheet tabs that the worksheet
itself is
hidden!
Your only question is "does hiding the tab make the sheet hidden, too?"
If so, yes, the sheet is hidden. Unless the sheets are password
protected in some way, though, they can be rather easily unhidden, too,
by the user.

Did you have some other question?
 
M

Mike Fogleman

In the UserForm code window put this code for the Option Buttons:

Private Sub OptionButton1_Click()
Sheet1.Visible = True
Sheet2.Visible = True
Sheet3.Visible = False
Sheet4.Visible = False
End Sub

Private Sub OptionButton2_Click()
Sheet1.Visible = True
Sheet2.Visible = False
Sheet3.Visible = True
Sheet4.Visible = False
End Sub

Private Sub OptionButton3_Click()
Sheet1.Visible = True
Sheet2.Visible = False
Sheet3.Visible = False
Sheet4.Visible = False
End Sub

Private Sub OptionButton4_Click()
Sheet1.Visible = True
Sheet2.Visible = False
Sheet3.Visible = False
Sheet4.Visible = True
End Sub

Mike F
 
J

JBeaucaire

The code above would work, but without some extra work on your part,
users would be able to easily make the other sheets visible again.

Use the VeryHidden attribute to make the sheets unviewable without more
VBA code.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top