View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
scottwilsonx[_9_] scottwilsonx[_9_] is offline
external usenet poster
 
Posts: 1
Default Close where no password?

Hello everyone. Can someone help me with this problem:

I have this code, where the macro asks the user to enter password, an
if the password = t1 then it lets them continue in the file. If the
try their password 3 times incorrectly then it closes. However a
present if they enter no at "ready to continue?" it does nothing an
still alllows the user access.

I need to add a line in so that if they decide not to enter a username
then it closes the worksheet.

Thanks for all help. Code below:

Sub Password()
Dim t1 As String
Dim I1 As Integer
Dim I2 As Integer
I1 = MsgBox("Ready to continue?", 292, "We need to check that you ar
an authorised user!!")
If I1 = 6 Then
For I2 = 1 To 3
t1 = InputBox("name", "input", "")
If t1 = "scott" Or t1 = "scott wilson" Then
Worksheets("Last user").Visible = True
Sheets("Last User").Select
ActiveCell = t1
Worksheets("Last User").Visible = False
Worksheets("Menu").Visible = True
Sheets("Menu").Select
Exit Sub
Else
Worksheets("Last User").Visible = True
Worksheets("Last User").Select
ActiveSheet.Range("a2").Select
Selection.Insert Shift:=xlDown
Selection = t1
Worksheets("Last User").Visible = False
End If
Next I2

MsgBox "Please try again " & Chr(13) & "Entry not recognised " & t1
ActiveWorkbook.Close savechanges:=False
End If

End Sub


Thanks
Scott

--
Message posted from http://www.ExcelForum.com