+ Reply to Thread
Results 1 to 5 of 5

Verify Password/Login Userform to worksheet Help

  1. #1
    Registered User
    Join Date
    05-19-2014
    Posts
    2

    Exclamation Verify Password/Login Userform to worksheet Help

    I am trying to create a log-in page on a userform, frmlogin in "sheet3."
    The userform is simply a textbox, Username (txtuser) and a textbox, Password (txtpass).
    Command Button is cmdcheck

    I want the User to enter their username and password and for my macro to verify that they match referencing data in a seperate worksheet, (Sheet6).

    Upon verification I want the user to be unloaded on "sheet1"

    I am currently getting this message:
    "unable to get vlookup property of the worksheetfunction class"

    I am new to vba and have spent way too much time on this one small issue. Please help me someone!!!!

    Private Sub cmdcheck_Click()
    Dim Username As String
    Username = txtuser.Text
    Dim password As String
    password = txtpass.Text


    'Check to see if data is entered into field: txtUserNameIn
    If IsNull(Me.txtuser) Or Me.txtuser = "" Then
    MsgBox "You must enter your username.", vbOKOnly, "Required Data"
    Me.txtuser.SetFocus
    Exit Sub
    End If

    'Check to see if data is entered into field: txtPasswordIn
    If IsNull(Me.txtpass) Or Me.txtpass = "" Then
    MsgBox "You must enter your Password (case sensitive).", vbOKOnly, "Required Data"
    Me.txtpass.SetFocus
    Exit Sub
    End If

    'Check to see if the Username & Password entered is a valid username in the 'User Register'
    '****************
    If Username = WorksheetFunction.VLookup(Me.txtuser.Value, Range("pass"), 2, 0) Then
    '****************
    If password = WorksheetFunction.VLookup(Me.txtuser.Value, Range("pass"), 3, 0) Then
    MsgBox "Password & Username Accepted"
    Unload Me
    Sheets("landing").Select
    Range("A1").Select
    Else
    MsgBox "Username & Password Combination Not Accepted"
    Unload Me

    End If
    End If

    End Sub

  2. #2
    Valued Forum Contributor
    Join Date
    09-01-2013
    Location
    Dallas, TX
    MS-Off Ver
    Excel 2010
    Posts
    324

    Re: Verify Password/Login Userform to worksheet Help

    I took your function out being I don't know what it's doing so back your code up and try this:

    In the code, Edit these two lines if needed. Default searches username in column B. If the password is directly to the right of the username then just edit the 1st line column #:

    muser = Application.Match(Username, ul.Columns(2), 0) 'set username column number 2 = Column B
    mpass = Application.Match(password, ul.Columns(2).Offset(0, 1), 0) 'set password column. offset (0, 1) = 1 column over right

    I haven't tested but should work.


    Please Login or Register  to view this content.
    Last edited by playaller; 05-22-2014 at 10:08 PM.


    Shelton A.
    If Helpful, Add Reputaion!

  3. #3
    Registered User
    Join Date
    05-19-2014
    Posts
    2

    Re: Verify Password/Login Userform to worksheet Help

    Shelton,
    Thank You for jumping in and helping! I am now getting "Subscript out of range" and my Set ul = Sheets("Sheet6") is being highlighted.

    I think it is because sheet6 is not the active worksheet. Any ideas on how to remedy this?


    -Jeff

  4. #4
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Verify Password/Login Userform to worksheet Help

    This is an interesting problem that is cross posted at
    http://www.ozgrid.com/forum/showthread.php?t=188541

    This link explains why and how to cross-post gracefully.
    http://www.excelguru.ca/content.php?184
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  5. #5
    Valued Forum Contributor
    Join Date
    09-01-2013
    Location
    Dallas, TX
    MS-Off Ver
    Excel 2010
    Posts
    324

    Re: Verify Password/Login Userform to worksheet Help

    Try this update which gives excel more details of the password sheet location. Also since I can't see the workbook make sure Sheet6 is spelled Sheet6. Try the code below and if still an error could you upload the wb for a quicker resolve.


    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Password for custom userform login only works with text passwords
    By Nitefox in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-23-2014, 06:45 PM
  2. Code to verify password on login
    By Nitefox in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-23-2014, 03:05 PM
  3. Username/Password Login userform code
    By Nitefox in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-17-2014, 02:43 PM
  4. How to create a password login through a userform
    By xia0jj in forum Excel Programming / VBA / Macros
    Replies: 19
    Last Post: 01-10-2014, 05:59 AM
  5. 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

Tags for this Thread

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