Easy way to add column as first column?

csotstot

New Member
Joined
Jun 1, 2017
Messages
24
Good Morning and Happy New Year all...
I often have to add special columns (eg. date columns) into my queries. Some, like the date columns, fit best (for my audience) at the beginning of the table. I'm just looking to save a step or two if there is a simple way to place the column at the beginning of the table (or a specific location) when it's created, rather than moving the column in a separate step after the fact...
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
select each column in order you want (with Ctrl key) then Remove Other Columns
all columns should be selected
or use
Table.ReorderColumns()
 
Last edited:
Upvote 0
Hi Sandy...
Thanks for the note, but what I was looking to try to do was something akin to wrapping Table.AddColumn() inside of Table.ReorderColumns(), rather than creating the additional column and then moving it...
I can always select the column and do a Move to Beginning (or Ctrl+Select as you noted for setting specific orders of all columns) as a step after the creation step, but was hoping to eliminate additional steps (kinda like setting data types as part of the creation step rather than after creation)… From my reading so far it doesn't appear to be possible (I also found a voting thread for adding the feature, but it's dated Feb 2017-so I doubt we'll see any implementation...
 
Upvote 0
wrapping Table.AddColumn() inside of Table.ReorderColumns(),
these are TWO steps, the first inside the second but in a single line

you can do that manually in single line but still it will be two steps

you can write a function to do that if there is a pattern of structure, but if no pattern it doesn't make sense but of course you can try :)
 
Last edited:
Upvote 0
Hi Sandy...
True... :).
As your note implies, wrapping functions manually wouldn't yield any efficiencies and would just be confusing for anyone looking at the M code later if I'm not around.
Since there doesn't appear to be an undocumented column creation function that does allow setting order as an option, It looks like the simplest thing is just going to be create the column and then move it.
Fortunately, if the worst thing that happens in my life today is having to add a step to move a column; I'm not doing too bad in the overall scheme of things! :)
Have a great morning and enjoy the new year!!!
 
Upvote 0

Forum statistics

Threads
1,226,125
Messages
6,189,133
Members
453,525
Latest member
compugor

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