How to swop the excel column ?

paulyeo1111

New Member
Joined
Dec 24, 2021
Messages
2
Office Version
  1. 365
Platform
  1. Windows
Hi All

This is my first post.

I have excel file with below format :-

CUST_ID.............COMPANY...........INVOICE............DATE......................AMOUNT
1234.....................ABC........................123045..............12/11/2020.........1500
2324.....................XYZ........................120345...............11/11/2020.........2500
4544.....................DEF........................12345..................10/11/2020.........3500

May i know how to transform the above file structure to below format :-

COMPANY...........CUST_ID.........INVOICE..............DATE......................AMOUNT
ABC.........................1234...............123045.................12/11/2020......1500
ZYX .........................2324..............120345.................11/11/2020.......2500
DEF................... 4544..............12345...................10/11/2020........3500

Hope some one can advise me.

As i have many CSV file , i need to swop the column.

Paul
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
Load your file with power query, it needs just one step
 
Upvote 0
Solution
Hi
what about
VBA Code:
Sub swap()
    With Sheets("sheet1").Cells(1).CurrentRegion
        .Resize(, 2) = Application.Index(.Resize(, 2), Evaluate("row(1:" & .Cells(Rows.Count, 1).End(xlUp).Row & ")"), Array(2, 1))
    End With
End Sub
 
Upvote 0
Load the data into Excel, then select Column A, hold down the Shift Key and place the cursor over the edge of the select column (cursor will turn to four arrows point away from the center), with the Shift Key still down left-click and drag the column to wherever you want (the column line between the columns will highlight) and release the mouse click and Shift Key.
 
Upvote 0

Forum statistics

Threads
1,203,693
Messages
6,056,760
Members
444,889
Latest member
ibbara

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