This is the codes i'm using for the user form i've created:
Option Explicit
Private Sub Login_Click()
Dim user As Variant
user = LoginPage.UserName.Value
Dim pw As Variant
pw = LoginPage.UserName.Value
Dim try As Integer
try = 0
Dim formula As String
formula = "C" & WorksheetFunction.Match(user, Sheet2.Range(Cells(9, 2), Cells(18, 2)), 0)
Dim successlogin As String
successlogin = "Welcome back " & user & "! Your login will be recorded down."
If try < 4 Then
If WorksheetFunction.CountIf(WorksheetFunction.Indirect(Sheet2.Range(Cells(9, 2), Cells(18, 2))), pw) = 1 Then
MsgBox (successlogin)
Unload Me
Else
MsgBox ("Either your username or password is incorrect, please try again.")
try = try + 1
End If
Else
MsgBox ("You have failed to enter the correct login key within 3 attempts. The file will now be closed.")
Unload Me
End If
End Sub
What i'm trying to do can be separated into different phase:
Phase 1: Code the userform so that the UserName and password inputted can be matched with those in data pool and if it's matched, Login successful, or else, failed.
Phase 2: Code to record down all the successful login into Sheet 2.
Phase 3: Disable the [exit "x"] button of the login userform.
PLEASE~~!!! ANYONE?! PLEASE HELP ME!!
Bookmarks