Hello there
Could you guys tell me how to fix this error, i tried sheet2.activate but i did not worked. It says "Error 424, object not found."
Could you guys tell me how to fix this error, i tried sheet2.activate but i did not worked. It says "Error 424, object not found."
VBA Code:
Private Sub Reg1_AfterUpdate()
'Check to see if value exists
[COLOR=rgb(85, 57, 130)]If WorksheetFunction.CountIf(Sheet2.Range("B:B"), Me.Reg1.Value) = 0 Then <-- Error here[/COLOR]
MsgBox "This is an incorrect ID"
Me.Reg1.Value = ""
Exit Sub
End If
'Lookup values based on first control
With Me
.Reg2 = Application.WorksheetFunction.VLookup(CLng(Me.Reg1), Sheet2.Range("Lookup"), 2, 0) <-- Error here
.Reg3 = Application.WorksheetFunction.VLookup(CLng(Me.Reg1), Sheet2.Range("Lookup"), 3, 0)
.Reg4 = Application.WorksheetFunction.VLookup(CLng(Me.Reg1), Sheet2.Range("Lookup"), 4, 0)
.Reg5 = Application.WorksheetFunction.VLookup(CLng(Me.Reg1), Sheet2.Range("Lookup"), 5, 0)
.Reg6 = Application.WorksheetFunction.VLookup(CLng(Me.Reg1), Sheet2.Range("Lookup"), 6, 0)
End With
End Sub