VBA error search 2 phrases delete row

This code should look for the word multiweight in column A sheet Net_Rates_1
If it finds this, it should look down column A for "Ground CA".
If it finds it, it should delete the row.
I am getting an error "Object does not support this property or method".
Can anyone help??

Application.ScreenUpdating = False
    Dim rngFindH1 As range
    Dim rngFindH2 As range
    Set rngFindH1 = ActiveSheet.range("A:C").Find("*Multiweight*")
    If (rngFindH1 Is Nothing) Then
        Set rngFindH2 = ActiveSheet.range("A:A").Find("Ground CA", after:=rngFindH1.Cells(1, 1))
    End If
    If (rngFindH1 Is Nothing) Or (rngFindH2 Is Nothing) Then

    End If
End Sub

Open in new window

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.



Martin LissOlder than dirtCommented:
If rgonzo1971's solution doesn't help then please supply a workbook.
Saurabh Singh TeotiaCommented:

Here is the revised code for your reference where i did couple of changes..

Application.ScreenUpdating = False
    Dim rngFindH1 As Range
    Dim rngFindH2 As Range
    Set rngFindH1 = ActiveSheet.Range("A:A").Find("*Multiweight*")
    If Not (rngFindH1 Is Nothing) Then Set rngFindH2 = Range("A:A").Find("Ground CA", after:=rngFindH1)
    If Not (rngFindH1 Is Nothing) Or Not (rngFindH2 Is Nothing) Then rngFindH2.EntireRow.Delete
End Sub

Open in new window

Starting with this line...

 Set rngFindH1 = ActiveSheet.range("A:C").Find("*Multiweight*")

Open in new window

Because in this line you are searching for multiweight from A Column To C Column so it will give you an error if multiweight exist in B and C Column of your data in subsequent lines...

In additional you don't need cells(1,1) in the find command you are giving if you want to search after multiweight line...


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.