runtime error '1004': Unable to FindNext property of Range class

Pookiemeister

Well-known Member
Joined
Jan 6, 2012
Messages
563
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
I'm aware that the find function doesn't do a multiple criteria search (2 in this case), which I need done, so I declared two range variables so I can individually search for the 2 criterias. The first criteria is located in column "G" and the second is located in column "D". Once the criteria is verified, it offsets a few times in that row to obtain the value of that cell and adds it to the other values found. Once that row is complete I need it to FindNext and check if there are any values there and continue the process until the the end condition is met and then it will exit the loop.
I get the runtime error when the first FindNext appears.
Code:
Set rSearchLotValue = .FindNext(rSearchLotValue)
I know that this explanation might be very confusing so I included a large portion of the code to hopefully clarify what I am wanting to achieve.
Thank you
Code:
With ActiveSheet.Range("G:G")        
        Set rSearchRng = .Find(what:=Me.TextBox4.Value, lookat:=xlWhole, LookIn:=xlValues)
        
        If Not rSearchRng Is Nothing Then
            FirstRngCellAddress = rSearchRng.Address
            rSearchRng.Select
            Do
                With ActiveSheet.Range("D:D")
                    Set rSearchLotValue = .Find(what:=Me.TextBox1.Value, lookat:=xlWhole, LookIn:=xlValues)


                    If Not rSearchLotValue Is Nothing Then
                        rSearchLotValue.Select
                    End If
                End With
                sProductCodeValue = rSearchRng.Offset(, -5).Value
                sSearchLotValue = rSearchRng.Offset(, -3).Value
                Do
                    If rSearchRng.Value = TextBox4.Value And sSearchLotValue = Me.TextBox1.Value And sProductCodeValue = TextBox2.Value Then
                        rSearchRng.Offset(, -3).Select
                        lProductTotal = 0
                        rSearchRng.Offset(, 1).Select
                        lProductTotal = lProductTotal + rSearchRng.Offset(, 1).Value
                        rSearchRng.Offset(, 3).Select
                        lProductTotal = lProductTotal + rSearchRng.Offset(, 3).Value
                        rSearchRng.Offset(, 5).Select
                        lProductTotal = lProductTotal + rSearchRng.Offset(, 5).Value
                       Set rSearchLotValue = .FindNext(rSearchLotValue)
                        FirstRngCellAddress = rSearchRng.Address
                    Else
                        GoTo continue
                    End If
                Loop While rSearchRng.Value = TextBox4.Value And sSearchLotValue = Me.TextBox1.Value And sProductCodeValue = TextBox2.Value And rSearchRng.Address <> FirstRngCellAddress
continue:
                Set rSearchRng = .FindNext(rSearchRng)
            Loop While Not rSearchRng Is Nothing And rSearchRng.Address <> FirstRngCellAddress
        ElseIf rSearchRng Is Nothing Then
            MsgBox "The work order number " & frmSDPFLineSelect1.TextBox4.Value & " was not found for the " & sLineName & " line. Please confirm that the correct production line was selected and try again.", vbCritical, "Incorrect Selection"
            ActiveWorkbook.Close
            frmSDPFLineSelect1.Show
        End If
    End With
 
Last edited:

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
Try
Code:
Set rSearchLotValue = Range("D:D").FindNext(rSearchLotValue)
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,215,507
Messages
6,125,207
Members
449,214
Latest member
mr_ordinaryboy

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