Forum Discussion
David_Wor
Feb 14, 2021Copper Contributor
How to loop a macro, for columns
I am trying to loop a macro crossed several columns… can you tell me how to do that rather than copy and pasting. I am starting in column Hand I want to loop all of the columns to the right until don...
HansVogelaar
Feb 14, 2021MVP
Try this:
Sub CopyData()
Dim c As Long
Dim n As Long
n = Cells.Find(What:="*", SearchOrder:=xlByColumns, SearchDirection:=xlPrevious).Column
For c = 8 To n
Columns(1).Value = Columns(c).Value
Cells(2, c).Resize(2).Value = Cells(2, 7).Resize(2).Value
Next c
End SubDavid_Wor
Feb 15, 2021Copper Contributor
Hans - Thank you. This is so much better! I am very glad that I posted this and that you saw it.