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
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