Automatically Reorder 77 Columns based on row 1 contents

slam

Well-known Member
Joined
Sep 16, 2002
Messages
848
Office Version
  1. 365
  2. 2019
We have a system with an excel export, but the columns are not in the order we need, nor are they even in the same order each time we perform this export.

Is it possible to redefine the columns in Excel with some VBA? I would want this done based on the contents of A1 through CY1. These values are consistent and unique.

If anyone can point me in the right direction, I would greatly appreciate it!
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
first off i would look at macro recorder, record your actions you use to fix the file, then it could be refined for regular use
 
Upvote 0
first off i would look at macro recorder, record your actions you use to fix the file, then it could be refined for regular use

Since the columns are always in a different order when exported, I don't think I could use a macro recorder. I think I'd have to define the order of the columns in the VBA, based on the contents of row 1.
 
Upvote 0
Yeah, row 1 is the headers, and all header values are unique.
 
Upvote 0
so potentially the header may be the key to getting it to sort
 
Upvote 0

Forum statistics

Threads
1,213,560
Messages
6,114,309
Members
448,564
Latest member
ED38

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