I'm trying to write a sub that loops through the values in the C column of the "Changes" worksheet and looks for the corresponding value in the "4Q2017" worksheet. If there is a match, the cell two columns away in the "Changes" worksheet should take the value 72 columns away from the matched value in the "4Q2017" worksheet.
I have an "object required" error; how can I improve this code? Thank you!
I have an "object required" error; how can I improve this code? Thank you!
Code:
Sub GetData()
Dim rng1 As Range, rng2 As Range, cell As Range, cell2 As Range
Set rng1 = Worksheets("Changes").Range("A3:A100")
Set rng2 = Worksheets("4Q2017").Range("C2:C100")
For Each cell In rng
If Not IsEmpty(cell.Value) Then
For Each cell2 In rng2
If cell2.Value = cell Then
cell.Offset(0, columnOffset:=2) = cell2.Offset(0, 72).Value
End If
Next cell2
End If
Next cell
End Sub