Search code examples
excelexcel-formulaexcel-2010excel-2007

Sorting by alternate numbered rows without losing data


I want to sort by Sr.No. in ascending order in such a way that I get both Name and ID in the same order.Since the ID has no numbering alongside I am facing difficulty in doing so, can anyone please help .

I want to sort by Sr.No. in ascending order in such a way that I get both Name and ID in the same order.Since the ID has no numbering alongside I am facing difficulty in doing so, can anyone please help


Solution

  • Sort By Every Other Row

    enter image description here

    Add a helper column with the following formula in the first cell (row 2)...

    =IF(MOD(ROW(),2),C1+1,2*A2-1)
    

    ... and copy down.

    Now sort this column instead.

    Edit

    Here's another way to spill the sorted data in another place:

    enter image description here

    =LET(data,A2:B13,iCol,1,
        i,INDEX(data,,iCol),
        f,IF(i>0,2*i-1,0),
        s,VSTACK(0,DROP(IF(f>0,f+1,0),-1)),
    SORTBY(IF(data="","",data),f+s))