This wont stop access to a sheet but if you reference a hidden sheet i
you code to open the shet when the password input is true you should b
ok, you will see that i have commented out some code what this does i
reference a sheet called "hidden" and record the wrong entries tha
have been made in the input box, if you want to use this just remov
the apostrophies. The last line before end sub closes and saves th
active workbook. You could place this code in the open worksheet_even
so when the sheet is attempted to be opened it displays the messag
box, but if they get the password wrong 3 times it closes and saves th
whole program. t1 would be your list of valid passwords but you coul
reference a named list.
Sub msg()
'
' msg Macro
' Macro recorded 22/04/04 by Kellogg
'
' Keyboard Shortcut: Ctrl+Shift+M
Dim t1 As String
Dim I1 As Integer
Dim I2 As Integer
I1 = MsgBox("continue?", 292, "Choose Password")
If I1 = 6 Then
For I2 = 1 To 3
t1 = InputBox("name", "input", "")
If t1 = "simon" Or t1 = "mark" Then
ActiveCell = t1
Exit Sub
' Else
'Worksheets("hidden").Visible = True
'Worksheets("hidden").Select
'ActiveSheet.Range("a2").Select
'Selection.Insert Shift:=xlDown
'Selection = t1
'Worksheets("hidden").Visible = False
End If
Next 'I2
MsgBox "Please try again " & Chr(13) & "Entry not recognised "
t1
ActiveWorkbook.Close savechanges:=False
End If
End Sub
HTH
Simo
--
Message posted from
http://www.ExcelForum.com