Search code examples
excelsortingif-statementexcel-formulaworksheet-function

Data fill in specific pattern


I am trying to fill data in MS Excel. I am given following pattern:

1 2
1 
1 
2 5 
2 5
2 
3 
3 6
3  
4 
4 
5 4

And I want my output in following format:

1 2
1 2
1 2
2 5 
2 5
2 5
3 6
3 6
3 6
4 
4 
5 4

I tried using if(b2,b2,c1) in column 3. but that doesn't solve the problem for a=3 and a=4.

Any idea how to do this in Excel?


Solution

  • With sorting thus:

    SO18568673 example

    (the effect of which in this case is merely to move 6 up once cell) and a blank row above:

    =IF(AND(A2<>A1,B2=""),"",IF(B2<>"",B2,C1)) 
    

    In C2 and copied down should get the result you ask for from the data sample provided.