Flip Columns

RiverRats

New Member
Joined
Aug 3, 2022
Messages
7
Office Version
  1. 365
Platform
  1. Windows
I have a report that imports the wrong way and I need to flip the columns. The report starts with Dec 21 in the left column and Jan 21 in the end column. Is there a quick way to flip the columns so they go Jan to Dec.

Thank you in advance for reading this.
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
you asked for quick - so I just recorded a macro to do the job of selecting and re-arranging the columns manually.

Its not pretty or elegant, but if your data is in columns A - L then this should get what you want ?

VBA Code:
Sub Macro1()
'
' Macro1 Macro
'

'
    Columns("K:K").Select
    Selection.Cut
    Columns("M:M").Select
    ActiveSheet.Paste
    Columns("J:J").Select
    Selection.Cut
    Range("N1").Select
    ActiveSheet.Paste
    Columns("I:I").Select
    Selection.Cut
    Range("O1").Select
    ActiveSheet.Paste
    Columns("H:H").Select
    Selection.Cut
    Range("P1").Select
    ActiveSheet.Paste
    Columns("G:G").Select
    Selection.Cut
    Range("Q1").Select
    ActiveSheet.Paste
    Columns("F:F").Select
    Selection.Cut
    Columns("R:R").Select
    ActiveSheet.Paste
    Columns("E:E").Select
    Selection.Cut
    Columns("S:S").Select
    ActiveSheet.Paste
    Columns("D:D").Select
    Selection.Cut
    Columns("T:T").Select
    ActiveSheet.Paste
    Columns("C:C").Select
    Selection.Cut
    Columns("U:U").Select
    ActiveSheet.Paste
    Columns("B:B").Select
    Selection.Cut
    Columns("V:V").Select
    ActiveSheet.Paste
    Columns("A:A").Select
    Selection.Cut
    Columns("W:W").Select
    ActiveSheet.Paste
    Columns("A:K").Select
    Selection.Delete Shift:=xlToLeft
End Sub
 
Upvote 0
Or you can use the formula in B1 (make one row below headers)
=INDEX($A$1:$L$1,0,COLUMNS(A1:$L$1)) and then using fill handle pull the data upto B2-L2
Assuming all headers are from A to L

1659526663394.png
 
Upvote 0
Another option to try

VBA Code:
Sub FlipCols()
  Dim c As Long
  
  For c = 2 To 12
    Columns(c).Cut
    Columns(1).Insert
  Next c
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,372
Messages
6,124,531
Members
449,169
Latest member
mm424

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top