I want to define a variable in a for loop as a specific cell that will change as the for loop iterates through. I am just unsure of the syntax to do so. This is what I have so far. How could I make this do what I just explained? Any help would be greatly appreciated.
Key = Sheet1.Columns("A:A").Rows("i")
If you need to refer to the cell as a Range object, then:
You must use the
Set
keyword when assigning to an object variable. ARange
is an object.If you need to refer only to the cell's value, then:
I declare
Key
as typeVariant
because cells may contain error values/etc. which will cause an error if you strictly define the variable as type likeString
orLong
, etc.