Error 424: Object Required using Find

Rfriend

Board Regular
Joined
May 10, 2021
Messages
73
Office Version
  1. 2010
Platform
  1. Windows
Hello,

I am trying to run a find loop and keep getting an object required error. I cannot determine why I am getting this error. This code ran great previously. Any ideas?

VBA Code:
Private Sub cmdEdit2_Click()
'   Page 1
    Dim findvalue As Variant
    Dim cNum As Integer
    Dim Staff_DataSH As Worksheet
'error handling
        On Error GoTo errHandler:
'hold in memory and stop screen flicker
    Application.ScreenUpdating = False
        Set Staff_DataSH = Sheet7
'check for values
    If Emp1.Value = "" Or Emp2.Value = "" Then
        MsgBox "There is nothing to edit"
        Exit Sub
    End If
'clear the listbox
    lstEmployee.RowSource = ""
'find the row to edit
    Set findvalue = Staff_DataSH.Range("B9:B").Find(What:=Me.Emp1.Value, LookIn:=xlValues, LookAt:=xlWhole)
'update the values
 With findvalue
    findvalue = Emp1.Value
    findvalue.Offset(0, 1) = Emp2.Value          ' this is where I error.  Emp1 is a unique ID#, Emp2 is the employee active status.
    findvalue.Offset(0, 2) = Emp3.Value
    findvalue.Offset(0, 5) = Emp4.Value
    findvalue.Offset(0, 6) = Emp5.Value
    findvalue.Offset(0, 3) = Emp6.Value
    findvalue.Offset(0, 4) = Emp7.Value
    findvalue.Offset(0, 15) = Emp8.Value
    findvalue.Offset(0, 8) = Emp9.Value
    findvalue.Offset(0, 10) = Emp10.Value
    findvalue.Offset(0, 17) = Emp11.Value
    findvalue.Offset(0, 18) = Emp12.Value
    findvalue.Offset(0, 19) = Emp13.Value
    findvalue.Offset(0, 20) = Emp14.Value
    findvalue.Offset(0, 21) = Emp15.Value
    findvalue.Offset(0, 22) = Emp16.Value
    findvalue.Offset(0, 11) = Emp17.Value
    findvalue.Offset(0, 23) = Emp18.Value
    findvalue.Offset(0, 24) = Emp19.Value
    findvalue.Offset(0, 25) = Emp20.Value
    findvalue.Offset(0, 26) = Emp21.Value
    findvalue.Offset(0, 27) = Emp22.Value
    findvalue.Offset(0, 28) = Emp23.Value
    findvalue.Offset(0, 29) = Emp24.Value
    findvalue.Offset(0, 30) = Emp25.Value
    findvalue.Offset(0, 31) = Emp26.Value
            With findvalue
                .Offset(0, 12) = Format(Me.Emp27.Value, "mm/dd/yyyy")
                .Offset(0, 13) = Format(Me.Emp28.Value, "mm/dd/yyyy")
            End With
    findvalue.Offset(0, 14) = Emp29.Value
    findvalue.Offset(0, 7) = Emp30.Value
    findvalue.Offset(0, 16) = Emp31.Value
 End With
    AdvFilterOutdata
    If Staff_DataSH.Range("AP9").Value = "" Then
       lstEmployee.RowSource = ""
    Else
        lstEmployee.RowSource = Staff_DataSH.Range("Outdata").Address(external:=True)
    End If
    On Error GoTo 0
          Exit Sub
errHandler:
       MsgBox "An Error has Occurred " & vbCrLf & _
       "The error number is: " & Err.Number & vbCrLf & _
        Err.Description & vbCrLf & "Please notify the administrator"
End Sub
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
I'm surprised it even gets that far, as this line will give an error
VBA Code:
Set findvalue = Staff_DataSH.Range("B9:B").Find(What:=Me.Emp1.Value, LookIn:=xlValues, LookAt:=xlWhole)
because the range is not valid.
 
Upvote 0
I'm surprised it even gets that far, as this line will give an error
VBA Code:
Set findvalue = Staff_DataSH.Range("B9:B").Find(What:=Me.Emp1.Value, LookIn:=xlValues, LookAt:=xlWhole)
because the range is not valid.
I just changed that to try something. The original range was B:B. Changed it back to get the original error.

1636732802484.png
 
Upvote 0
Try changing findvalue from Variant to Range.
 
Upvote 0
Try changing findvalue from Variant to Range.
I have messed with this for days and keep getting stuck at this point. The code runs a user form that searches an employee database the returns the info to a list box. The list box is a double click event that drops the "Emp#" values into the controls. From there I can edit and delete. Everything works except the edit.
 
Upvote 0
You should have a test after Range.Find to ensure search value has been found

try adding line in BOLD & see if problem still persists

Rich (BB code):
'find the row to edit
    Set findvalue = Staff_DataSH.Range("B:B").Find(What:=Me.Emp1.Value, LookIn:=xlValues, LookAt:=xlWhole)
    If findvalue Is Nothing Then Err.Raise 744

Dave
 
Upvote 0
You should have a test after Range.Find to ensure search value has been found

try adding line in BOLD & see if problem still persists

Rich (BB code):
'find the row to edit
    Set findvalue = Staff_DataSH.Range("B:B").Find(What:=Me.Emp1.Value, LookIn:=xlValues, LookAt:=xlWhole)
    If findvalue Is Nothing Then Err.Raise 744

Dave
I get the 744 error "Search text not found"
 
Upvote 0
I get the 744 error "Search text not found"

Then this probably answers the question to your original issue - Run-time error:91 Object variable or With Block variable not set.

Try searching for a value that you know exists & see what happens

Dave
 
Upvote 0
Is Emp1 a numerical value, or text?
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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