I am trying to compare a value to each cell in a range. Once there is a match, I want to set another variable to old the value that is offset 3 columns over.
For Each i In Worksheets("SFDC Input").Range("D2:D20").Cells
If ProductFamily = i Then
i.Offset(0, -3).Value = ID
End If
Next
ProductFamily is the value I am comparing to i. I want ID to be the value holder.
It looks as though your assignment ( =
) is backwards. You're setting i.Offset(0, -3).Value
to ID
instead of setting ID
to the value.
Try the following:
ID = i.Offset(0, -3).Value
From MSDN :
The = operator assigns the value on its right to the variable or property on its left.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.