Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 45
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 812
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Password protection/access kefee85 Excel Discussion (Misc queries) 2 May 14th 09 09:34 PM
Password Access to certain sheets Sheryl Excel Worksheet Functions 2 November 28th 06 09:39 PM
access password to worksheet mrt Excel Worksheet Functions 3 September 1st 06 10:19 PM
Password to access a worksheet tholman[_2_] Excel Programming 1 November 9th 03 03:17 PM
VBa, Password protected sheet fails to get unprotected with the same password Hans Rattink Excel Programming 3 July 28th 03 02:30 PM


All times are GMT +1. The time now is 10:26 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"