Efficiently reformat data layout

2019-02-21 05:41发布

问题:

I have several Excel spreadsheets with data layout like this raw data:

company company1    company2    company3
currency     $        Y          E
1/1/2013    32.68   12          3
1/2/2013    12.5    13          4
1/3/2013    45      45          8  

which basically are time series data grouped together. I need the final layout transformed into panel data, like this wanted panel data:

Since my observations are usually very large, it is not practical manually to reformat it.

Is there a macro code that can achieve such a goal?

回答1:

Turn on Record Macro if desired. In Excel, move the currency row out of the way. 'Reverse pivot' (as detailed here), sort the Table on Column A to Z, switch the order of Columns B and C and fill Column D with a lookup of the company name against your currency indicators.