VBA 424 error

hailstorm

New Member
Joined
Sep 14, 2019
Messages
34
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."


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
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
Do you have a Sheet2? This is referring to a sheet code name not a sheet name by the way. Go to the VBA window and look in the project explorer. The sheet code name is the name not in the brackets under microsoft excel objects.
 
Upvote 0
Try
Rich (BB code):
Sheets("Sheet2").Range("Lookup")
 
Upvote 0

Forum statistics

Threads
1,214,375
Messages
6,119,167
Members
448,870
Latest member
max_pedreira

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top