![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Board Regular
Join Date: Apr 2002
Location: Manchester UK
Posts: 133
|
I have a system to be used by many and there is one sheet where i only want people that know a password to be able to see it, is there a way that when someone clicks the sheet tab or a linking password that they are asked for a password???
|
|
|
|
|
|
#2 |
|
Board Regular
Join Date: Apr 2002
Location: Manchester UK
Posts: 133
|
Any One?????
|
|
|
|
|
|
#3 | |
|
MrExcel MVP
Join Date: Feb 2002
Location: Auckland, New Zealand
Posts: 4,209
|
Quote:
Notes 1) Change sPwd const to your password 2) Change the Sh.Name = "Sheet3" to your sheet name that you want password protected. '// Change to your password Const sPwd As String = "mypassword" Dim LastSheet Private Sub Workbook_SheetActivate(ByVal Sh As Object) Dim OK As String If Sh.Name = "Sheet3" Then OK = InputBox("Please enter password", "Sheet Sentry") If OK <> sPwd Then Sheets(LastSheet).Activate End If End Sub Private Sub Workbook_SheetDeactivate(ByVal Sh As Object) LastSheet = Sh.Name End Sub |
|
|
|
|
|
|
#4 |
|
New Member
Join Date: Mar 2002
Location: Paul
Posts: 34
|
What syntax would I use to employ the PasswordChar function on this example?
TIA Cheers - Paul |
|
|
|
|
|
#5 |
|
Board Regular
Join Date: Apr 2002
Location: Manchester UK
Posts: 133
|
i have but this code into VBA but it doesnt seem to do anything, maybe it me but does anyone know how to make it work??
|
|
|
|
|
|
#6 |
|
Board Regular
Join Date: Apr 2002
Location: Manchester UK
Posts: 133
|
I am also using 2000 if that makes any difference,Any one, Please
|
|
|
|
|
|
#7 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Christchurch New Zealand
Posts: 1,030
|
put the code in the worksheet that you want the user asked for the password not in a module.
|
|
|
|
|
|
#8 |
|
Board Regular
Join Date: Apr 2002
Location: Manchester UK
Posts: 133
|
i have tried putting this code onto the sheet code but it still doesnt do anything is it meant to ask for the password when i click on the page or is anymore code needed??
|
|
|
|
|
|
#9 | |
|
MrExcel MVP
Join Date: Feb 2002
Location: Auckland, New Zealand
Posts: 4,209
|
Quote:
and Not the sheets code module as I specified See if this works. Also note the other Notes i made Good luck |
|
|
|
|
|
|
#10 |
|
Board Regular
Join Date: Apr 2002
Location: Manchester UK
Posts: 133
|
i have got the message box to pop up, but even though i have changed the password like you said when you enter the password and click ok you are taken back to your last sheet and if you press cancel it lets you in???
just to check this is what i changed the code to: '// Change to your password Const user12 As String = "mypassword" Dim LastSheet Private Sub Workbook_SheetActivate(ByVal Sh As Object) Dim OK As String If Sh.Name = "Passworded" Then OK = InputBox("Please enter password", "Sheet Sentry") If OK <> user12 Then Sheets(LastSheet).Activate End If End Sub Private Sub Workbook_SheetDeactivate(ByVal Sh As Object) LastSheet = Sh.Name End Sub |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|