Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Password to get access to certain sheet
Hi,
I need a macro that asks for a password to get access to another sheet. Lets say you have a button in sheet1 and when you click that button you get access to sheet2, if you have the right password, otherwise you dont. Thanks! //Thomas |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Password to get access to certain sheet
I need a macro that asks for a password to get access to another sheet.
Lets say you have a button in sheet1 and when you click that button you get access to sheet2, if you have the right password, otherwise you dont. This is doable with code such as follows. The insecurity is reprotecting sheet2 when the user is done. The following assumes the password is in cell B10 of sheet2. While it is "hidden" by making the font color match the cell interior color, it's easy for the user to find the password. 'sheet1 code Private Sub CommandButton1_Click() Dim ws As Worksheet Set ws = Worksheets("sheet2") ws.Unprotect ws.Visible = xlSheetVisible End Sub 'sheet2 code Private Sub Worksheet_Deactivate() Dim ws As Worksheet Set ws = Worksheets("sheet2") ' reset password; hide by setting ' font to white (invisible) ws.Range("B10").Font.ColorIndex = 2 ws.Protect ws.Range("B10") ws.Visible = xlSheetHidden End Sub HTH, Merjet |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Password protection/access | Excel Discussion (Misc queries) | |||
Password Access to certain sheets | Excel Worksheet Functions | |||
access password to worksheet | Excel Worksheet Functions | |||
Password to access a worksheet | Excel Programming | |||
VBa, Password protected sheet fails to get unprotected with the same password | Excel Programming |