Tuesday, 17 September 2013

Formula for transposing data from Row to Column: MS Excel

Formula for transposing data from Row to Column

Recently I have encountered a situation where I have to transpose the row data to column in Excel. The manual process was totally impossible due to high volume of data. One can easily understand the requirement from the below format: 

Original File Format:
Emp Code
Emp Name
Sal Month-01
Sal Month-02
…
Sal Month-41
111
Emp1
123
124
124
145
112
Emp2
…
…
…
…
113
Emp3
…
…
…
…
…
…
…
…
…
…
999
Emp999
…
…
…
…


Desired File:
Emp Code
Emp Name
Sal Month
Salary
111
Emp1
Sal Month-01
123
111
Emp1
Sal Month-02
124
…



111
Emp1
Sal Month-41
145
112
…
…
…
…
…
…
…
…
…
…
…
999
…
…
…

Solution Formula:

=IF(MOD(ROW(),42)=0,"",OFFSET($E$1,0,MOD(ROW()-1,42),1,1))
=IF(MOD(ROW(),42)=0,"",OFFSET($E$2,0,MOD(ROW()-1,42),1,1))
=IF(MOD(ROW(),42)=0,"",OFFSET($A$4,INT((ROW()-1)/42),0,1,1))
=IF(MOD(ROW(),42)=0,"",OFFSET($A$4,INT((ROW()-1)/42),1,1,1))

=IF(MOD(ROW(),42)=0,"",OFFSET($E$4,INT((ROW()-1)/42),MOD(ROW()-1,42),1,1))

No comments:

Post a Comment