(Solved) – VBA Error “Object variable or with block variable not set “

  • by
(solved)-–-vba-error-“object-variable-or-with-block-variable-not-set-“
Private Sub LoginMasuk_Click()
Dim Password As String 
Dim Level As String
Dim pass As String  

pass = MD5(TextBox2.Value) 
Set WsUserName = Sheets("Data")
Set RgUserPas = WsUserName.Range("A2:A20")
Set c = RgUserPas.Find(TextBox1.Value, LookIn:=xlValues, MatchCase:=False)

Password = c.Offset(0, 1).Value
Level = c.Offset(0, 2).Value 

If pass <> Password Then
    MsgBox "password yang anda masukan salah", vbCritical, "User Login"
    Exit SubElse
    If Level = "Admin" Then
        MsgBox "Selamat Datang " & TextBox1.text, vbInformation, "Message"
        'MsgBox "Anda Login Sebagai " & Level, vbInformation, "User Login"
            loginApp.Hide
                Sheets("Data").Visible = xlSheetVisible
                Sheets("Hai").Visible = xlSheetVisible
                Sheets("Halo").Visible = xlSheetVisible
            Menu_Admin.Label1.Caption = Level
            Menu_Admin.Show
        Call bersih
        Exit Sub
    ElseIf Level = "Siswa" Then
        MsgBox "Selamat Datang " & TextBox1.text, vbInformation, "Message"
        'MsgBox "Anda Login Sebagai " & Level, vbInformation, "User Login"
            loginApp.Hide
                Sheets("Data").Visible = xlSheetVeryHidden
                'Sheets("Data").Visible = xlSheetVisible
                Sheets("Hai").Visible = xlSheetVisible
                Sheets("Halo").Visible = xlSheetVisible
                Menu_Siswa.Label1.Caption = Level
                Menu_Siswa.Show
        Call bersih
        Exit Sub
    End If
End If
End Sub

and I getting error in code –>

Password = c.Offset(0, 1).Value

how i solve it

Leave a Reply

Your email address will not be published. Required fields are marked *