Keep Column order with changing column names when exporting to Excel and preserve cell formatting

MichaelSchulz

Board Regular
Joined
Apr 10, 2014
Messages
64
I receive a new Excel file each month. The names of two columns in that file will change each month because part of the column name references the month name.

I use Power Query to extract the data from the file, perform some transformations, and load the results to a different Excel file. The results are loaded into that Excel file as an Excel Table.

I formatted the Table columns with appropriate types and desired formatting, e.g. setting Text or Number etc., Left alignment, Font size, and so forth. In the External Table Data Properties I checked the box for Preserve column sort/filter/layout so that these formatting selections are applied to all records in the table when the data is refreshed.

The first time I did this, it was fine. The following month is when I had a problem. When I refreshed the data connection, the columns that changed names ended up being moved to the far-right end of the table. I think this was due in part to the effects of the "Preserve column sort/filter/layout." My guess is that since the column header name changed, it is interpreted as being a new column.

When I uncheck that box and refresh the data the column order does not change, which is what I want. However, only the first record retains the desired cell formatting. The remaining records have a different formatting.

What approach will result in keeping the desired column order and the desired formatting throughout the whole table when I refresh the data?
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.

Forum statistics

Threads
1,223,888
Messages
6,175,207
Members
452,618
Latest member
Tam84

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