Reputation: 1036
I have a For Each loop reading the values of K2 through K7.
It looks like this (this is not my full code):
For Each cell In Range("K2:K7")
'do stuff
Next cell
How can I get data from another column (such as A, B, C, D, E, F, G, H, I, or J) on the CURRENT row of the "For Each" loop.
For example, first the For Each loop will grab K2, then K3, then K4, then K5, then K6, then K7. How to make it grab K2 and A2, K3 and A3, K4 and A4, etc. in the same For Each loop?
For example:
For Each cell In Range("K2:K7")
A.CurrentRow.Value = acolumndata
B.CurrentRow.Value = bcolumndata
C.CurrentRow.Value = ccolumndata
'do more stuff
Next cell
Upvotes: 1
Views: 52
Reputation: 1609
One way to do this would be to use the Offset
property.
For example, to refer to the cell in Column A that's on the same row as the current cell
in Column K, you would use cell.Offset(0, -10)
, since Column A is 10 columns to the left of Column K.
Upvotes: 1