Sheets - Limited acces

D

Darin Kramer

Howdie....
I need only certain sheets to be visible, depending on who is looking.

I looked at the previous submitted query today, but that response doesnt
work for me.

I have Five sheets.
Sheets One to Three (no pun intended :) ) are visible all the time
Sheets Four and Sheet Five only visible to a selective audience.
I would like to write VBA so that when the user runs the macro it asks
for a password, or username, and then if the correct answer is inputted,
it unhides Sheets Four or Five.
Too adventurous?
Other ideas welcomed...

Thanks!!

D

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
 
B

ben

As to asking for the username and password, you can insert a USERFORM into
your VBA project that you can set a text box to use password characters to
hide the password (Excel 2003 I know for sure). As for hiding and unhiding
the sheets, Save the workbook with sheets four and five hidden eg....

Sheet4.Visible = xlSheetVeryHidden
Sheet5.Visible = xlSheetVeryHidden

hiding sheets will not work in a regular module (or at least i couldn't get
them too.) so you must put them in a worksheet module.
and when you verify username and password,

sheet4.visible = xlsheetvisible
sheet5.visible = xlsheetvisible
 
D

Darin Kramer

You make it sound so easy... :) However I have only worked with user
forms one... and it wasnt easy.
I will need to insert VB to get the USER form to run, and not sure how
to make it ask for a password...

Any help GREATLY appreciated!!!

Kind Reagrds

D


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
 
B

ben

the macro that they call to unhide the sheets would instead call your
userform, lets call it pass put on the the userfor one textbox named
textbox1 and one button named commandbutton1 with the title ok
insert the following code into the userform
to hide the password right click the textbox and set the password characters
property to "*" or any other character

Private Sub CommandButton1_Click()
On Error Resume Next
l = TextBox1.Text
If l <> "putyourpasswordhere" Then
MsgBox "I'm sorry that password is incorrect, please try again."
TextBox1.Text = ""
TextBox1.SetFocus
Exit Sub
End If
sheet4.visible = xlsheetvisible
sheet5.visible = xlsheetvisible
Unload Me
End Sub
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
Application.EnableEvents = False
Cells(1, 1).Value = "Date:"
Application.EnableEvents = True
End Sub
 

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

Similar Threads


Top