Object Variable or With Block Variable not set

Baziwan

New Member
Joined
Sep 4, 2018
Messages
32
Hi all , I'm having a bit of a problem with my code returning an error.

I'm trying to find a value in sheet(Dty) and return it to sheet(Pur).

I'm using the code below which I've used variants of before with no problem, but for this
I'm getting an 'object variable or With block variable not set' error on the rCl.offset.
I'm not sure how to rectify it. Can anyone help??
Code:
Sub UpdatePurchases() 
Dim Ws As Worksheet
Dim Ws5 As Worksheet
Dim Rw As Long
Dim sFind As String
Dim rCl As Range

Set Ws = Worksheets("Pur")
Set Ws5 = Worksheets("Dty")

With Ws.Range("Purchases")
    For Rw = 1 To .Rows.Count
        sFind = .Cells(Rw, 7).Text 
        
        With Ws5.Range("A1", Ws5.Cells(Rows.Count, "A").End(xlUp))
            Set rCl = .Find(sFind, LookIn:=xlValues, lookat:=xlWhole)
            Ws.Range("Purchases").Cells(Rw, 15).Value = rCl.Offset(0, 3).Value
        End With
    Next Rw
End With
End Sub
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
If you get that message again, Debug & hover over rCl in the code line above the error line. I suspect you will be informed that "rCl = Nothing" which means that the .Find(sFind, ... did not find anything. You need to investigate that.
 
Upvote 0

Forum statistics

Threads
1,214,397
Messages
6,119,273
Members
448,883
Latest member
fyfe54

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