• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

How to Re-Arrange columns on same sheet by column name or column index no?

Hii @Chirag R Raval

Please find the attached solution Using Power Query.

It is very easy in power Query,

Reorder Column Formula
= Table.ReorderColumns(#"Changed Type",{"CUSTOMER", "BRAND", "ORDER_DP", "BLEND", "MATERIAL", "UNIT_CODE", "ORD_UNIT", "QUANTITY", "EX_PRICE", "VALUE", "SRNO", "TAGNO", "SEASON", "AREACODE", "CUST_GRP", "BLEND_DET"})

Delete Unwated Column
= Table.RemoveColumns(#"Reorderd Column",{"SEASON", "AREACODE", "CUST_GRP", "BLEND_DET"})


Regard
Rahul shewale

Dear Sir @rahulshewale1 ,

Great , I copy paste your construct in power query editor , & I can see success result......sorry, I realise recent , what you want to say....that time..

see below screen shot as my effort & as per your guideline,
YES-POWER QUERY.jpg

We can undo..in this query , as step by step, our every step applied in query editor .if we want we can just click on before steps, & database changed & stay in before condition.. just great...

Really I am very new to power Query..But , thank you very much for flashing me towards, amazing this Power Query tool.

My hunger or curiosity for know / learn power query , you doubled now...

Tthank you very much.

Regards,

Chirag Raval
 
Dear Sir @Marc ,

Thank you very much for your kind guideline...

I will check it all and try to understand that things & revert back you soon.

Regards,

Chirag Raval
 
It's just the use of an Excel basics : INDEX function …
So before running any code, see the Excel inner help (not VBA one).

Sorry as my previous post has nothing to do with PowerQuery.

Another way to rearrange columns : an advanced filter …
 
Dear Sir,

Wow, How many ways there are?

That's really amazed if to know how to rearrange columns through Advance Filter way.....

Please sir,

Can you explain that?

Regards,

Chirag Raval
 
First it depends on the real need.

If you have worksheet #1 with header columns like A B C D E F G H I J K L
and you need in worksheet #2 columns like A B D E L K I C (whatever)
with this headers already in this worksheet #2
so you just need a single codeline to achieve this !​
Code:
Worksheets(1).UsedRange.AdvancedFilter xlFilterCopy, , Worksheets(2).UsedRange.Rows(1)
As always, before writing any code :
« What Excel can do for my need ? » (remember TEBV rule)

As it's the same rule when using INDEX worksheet function in a VBA code …
 
Back
Top