For each statement and Error 424

haneefach

New Member
Joined
Jan 25, 2018
Messages
2
While running the below code, I am getting "Run time error 424 - Object required" on line no (6). Please help me to sort out. Thanks

1) Sub test ()
2) Dim ws as Worksheet, Sr as Range, c as Range
3) Set ws = Activesheet
4) With ws
5) Set Sr = Range(.cells(2,2), .cells(10,2))
6) For Each c In Sr
7) If c.Value = "a" then c.offset (0,1).value = "b"
8) Next
9) End with
10) End Sub
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
Welcome to the board.

It works for me.

The only possible issue I see is this line
Set Sr = Range(.cells(2,2), .cells(10,2))
should probably be
Set Sr = .Range(.cells(2,2), .cells(10,2))
 
Upvote 0

Forum statistics

Threads
1,223,909
Messages
6,175,312
Members
452,634
Latest member
cpostell

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