+ Reply to Thread
Results 1 to 7 of 7

Excel 2007 error with code for creating passwords

Hybrid View

  1. #1
    Forum Expert
    Join Date
    07-16-2010
    Location
    Northumberland, UK
    MS-Off Ver
    Excel 2007 (home), Excel 2010 (work)
    Posts
    3,054

    Re: Excel 2007 error with code for creating passwords

    OK, I actually tried putting the code in and testing it this time. It doesn't like you using either Name or Permission as variables, but a quick bit of renaming (and some trimming so I didn't need your whole workbook) gave this code, which works...

    Sub Login()
    
    Dim ValidLogin As Boolean
    Dim ReTries As Integer
    Dim Perm As Range
    Dim UName
    
    ValidLogin = False
    ReTries = 0
    
    While Not (ValidLogin) And ReTries < 3
      UName = Application.InputBox("Please Enter Name", "Login", "Enter Name Here", Type:=2)
    
      Set Perm = Sheets("Sheet3").Range("A1:A4").Find(UName, LookAt:=xlWhole)
    
      If Perm Is Nothing Then
        MsgBox ("Invalid Name Entered!")
    
        ReTries = ReTries + 1
    
      Else
         ValidLogin = True
    
         Select Case Perm.Offset(0, 1).Value
           Case "admin": MsgBox "Admin"
           Case "finance": MsgBox "Finance"
           Case "superuser": MsgBox "Superuser"
           Case "user": MsgBox "User"
           Case Else: MsgBox "Unknown user group"
         End Select
    
      End If
    
    Wend
    
    If Not (ValidLogin) Then
        Application.Quit
    End If
    
    End Sub
    Want to work from there?

  2. #2
    Registered User
    Join Date
    07-29-2010
    Location
    Cleveland, Ohio, US
    MS-Off Ver
    Excel 2007
    Posts
    20

    Re: Excel 2007 error with code for creating passwords

    Thanks for the help, I fixed the problem!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1