1

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.

1
  • is ID not being set as the value? Is that what you're asking? Commented Aug 14, 2013 at 13:40

1 Answer 1

11

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.