macro to rearrange columns

Bill_Davenport

New Member
Joined
Jul 25, 2017
Messages
13
hey, first time posting here if you require more information let me know. I have a spreadsheet that I want to make a macro to rearrange columns to be in a specific order, it's easy to do if the columns are always in the same spot, i could just record a macro and run it but I want this to be useable for multiple different users and depending on their individual preferences the columns will be in a different order

for example I want columns in order of column A, B, C, D etc
user1 may have columns in order of B, D, A, C and user 2 may have it in C, B, D, A.

luckily the column header names will always be consistant, can someone point me to a macro that will rerrange columns based on the column header and always put them in the same order? so if i run the macro on user1 or user2's spreadsheet it'll rearrange the data to the order I want.

sorry if this doesn't make sense, i'm just teaching myself how to do VB script lol, i've managed to make a script to format and highlight specific cells but i can't figure out how to do this.
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.

Forum statistics

Threads
1,214,619
Messages
6,120,550
Members
448,970
Latest member
kennimack

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