LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
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

 
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
why do all excel worksheets/workbooks close when I close one? Penny Excel Discussion (Misc queries) 1 November 29th 06 03:49 AM
how to automate opening a password protected excel file? e.g. a .xls that has a password set in the security tab. Daniel Excel Worksheet Functions 0 June 23rd 05 11:56 PM
Excel shoud not close all active books when clicking close button technomike Excel Discussion (Misc queries) 0 June 10th 05 05:35 PM
excel - Windows close button (x) should only close active workboo. CoffeeAdict Setting up and Configuration of Excel 3 February 8th 05 04:30 AM
Open en close a workbook with password Morrigu Excel Programming 1 April 16th 04 04:37 PM


All times are GMT +1. The time now is 04:01 AM.

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

About Us

"It's about Microsoft Excel"