Results 1 to 3 of 3

Code to verify password on login

Threaded View

  1. #1
    Forum Contributor
    Join Date
    09-16-2013
    Location
    Los Angeles, USA
    MS-Off Ver
    Excel 2011
    Posts
    620

    Code to verify password on login

    I found some username and password login code that I am editing for my needs, but I am having some trouble with it. I keep getting run time error '448': Named argument not found on the following line:
    MatchCase:=False, SearchFormat:=False)

    Code:
    Private Sub CommandButton3_Click()
        Dim RowNo As Long
        Dim Id As String, pw As String
        Dim ws As Worksheet
        Dim aCell As Range
    
        If Len(Trim(Me.Username.Value)) = 0 Then
            Me.Username.Value.SetFocus
            MsgBox "Username cannot be empty"
            Exit Sub
        End If
    
        If Len(Trim(Password)) = 0 Then
            Password.SetFocus
            MsgBox "Password cannot be empty"
            Exit Sub
        End If
    
        Application.ScreenUpdating = False
    
        Set ws = Worksheets("Users")
        Id = LCase(Me.Username.Value)
    
        Set aCell = ws.Columns(1).Find(What:=Id, LookIn:=xlValues, _
        LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
        MatchCase:=False, SearchFormat:=False)
    
        '~~> If match found
        If Not aCell Is Nothing Then
            RowNo = aCell.Row
            If Me.Password = aCell.Offset(, 1) Then
                Sheets("Users").Range("G1").Value = Usernames.Value
                Unload Me
            Else
                MsgBox "Unable to match UserID or PasswordID, Please try again", vbOKOnly
            End If
        Else '<~~ If not found
            MsgBox "Unable to match UserID or PasswordID, Please try again", vbOKOnly
        End If
    CleanExit:
        Set ws = Nothing
        Application.ScreenUpdating = True
        Exit Sub
    End Sub
    I have also attached my workbook.
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Username/Password Login userform code
    By Nitefox in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-17-2014, 02:43 PM
  2. username and password login
    By dc123 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 12-17-2013, 08:38 AM
  3. Ho to set Password Login for Workbook
    By AGrace in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-16-2012, 02:11 PM
  4. How to check/verify password of protected sheet is what you think it is
    By welchs101 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-06-2012, 02:31 PM
  5. How do I verify the password date of an excel workbook
    By develcom in forum Excel General
    Replies: 0
    Last Post: 06-12-2006, 07:20 PM

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