Automatically Reorder 77 Columns based on row 1 contents

slam

Well-known Member
Joined
Sep 16, 2002
Messages
919
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

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
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,223,894
Messages
6,175,250
Members
452,623
Latest member
Techenthusiast

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