none
Order one sheet's column based on mapping to another sheet RRS feed

  • Question

  • Hi, I have 2 excel sheets with same data but different column names like below:

    Sheet 1: Column1 Column2 Column3

    Sheet 2: C3 C1 C2

    Data Mapping: Column1-C1 Column2-C2  Column3-C3

    Question: How can I order Sheet 2 based on above mapping so that the result in sheet 2 will be:

    Resultant Sheet 2: C1 C2 C3

    Thanks in advance for your help.


    -Tushar Moondra




    • Edited by tusharmoon Friday, January 8, 2016 2:47 PM
    Friday, January 8, 2016 2:46 PM

Answers

  • >>>Question: How can I order Sheet 2 based on above mapping so that the result in sheet 2 will be:

    Resultant Sheet 2: C1 C2 C3<<<

    According to your description, if you need move column, you could refer to below code:

    Range("A1").Columns.Select
    Selection.Cut
    Range("C1").Columns.Select
    Selection.Insert Shift:=xlToRight

    Otherwise could you provide more information about your issue, for example sample code, screenshot etc., that will help us reproduce and resolve it.

    Thanks for your understanding.

    • Marked as answer by David_JunFeng Sunday, January 17, 2016 2:44 PM
    Monday, January 11, 2016 2:20 AM

All replies

  • Can you expand your question a bit, it's not clear to me what you want:

    Question: How can I order Sheet 2 based on above mapping so that the result in sheet 2 will be:

    Resultant Sheet 2: C1 C2 C3

    Do you mean you want to move the columns in sheet2 around so they match the column sequence in sheet 1 or are you trying to do something else?

    I it is just reordering columns, why not just select a column, copy it to another tab so you create a new tab with the correct order, then just delete the 'improperly ordered' tab?

    Is there some reason sheet2is in the 'wrong' order? Why not just fix the problem by making sheet2 correctly set up?

    Friday, January 8, 2016 4:13 PM
  • >>>Question: How can I order Sheet 2 based on above mapping so that the result in sheet 2 will be:

    Resultant Sheet 2: C1 C2 C3<<<

    According to your description, if you need move column, you could refer to below code:

    Range("A1").Columns.Select
    Selection.Cut
    Range("C1").Columns.Select
    Selection.Insert Shift:=xlToRight

    Otherwise could you provide more information about your issue, for example sample code, screenshot etc., that will help us reproduce and resolve it.

    Thanks for your understanding.

    • Marked as answer by David_JunFeng Sunday, January 17, 2016 2:44 PM
    Monday, January 11, 2016 2:20 AM