Forum Discussion
grantmcyorku
Dec 23, 2021Copper Contributor
Help Transposing every 2 Columns to Rows
Hoping someone can help me out. I'm looking for an automated way to transpose every 2 columns to rows. I want to go from this: To this: Thanks!
HansVogelaar
Dec 23, 2021MVP
Run this macro:
Sub Transform()
Dim r As Long
Dim c As Long
Dim n As Long
Application.ScreenUpdating = False
n = Cells(1, Columns.Count).End(xlToLeft).Column
For c = 1 To n Step 2
r = r + 1
Cells(1, c).Copy Destination:=Cells(r, 1)
r = r + 1
Cells(1, c + 1).Copy Destination:=Cells(r, 1)
Next c
Cells(1, 2).Resize(1, n - 1).Clear
Application.ScreenUpdating = True
End Sub
- grantmcyorkuDec 23, 2021Copper ContributorThanks. Hans Vogelaar. That didn't quite work for me, but got me looking into creating my own macros for the first time, and I now have it working.
Cheers!