Economics Database Transpose (Keep Formula References)

viktor4e

New Member
Joined
Jun 30, 2014
Messages
16
Hi everyone,

Very frequently I have economic databases in the following format in excel:

[TABLE="width: 345"]
<colgroup><col span="5"></colgroup><tbody>[TR]
[TD]Country[/TD]
[TD]2010[/TD]
[TD]2011[/TD]
[TD]2012[/TD]
[TD]2013[/TD]
[/TR]
[TR]
[TD]China[/TD]
[TD]1[/TD]
[TD]2[/TD]
[TD]3[/TD]
[TD]4[/TD]
[/TR]
[TR]
[TD]US[/TD]
[TD]2[/TD]
[TD]3[/TD]
[TD]4[/TD]
[TD]5[/TD]
[/TR]
[TR]
[TD]EU[/TD]
[TD]3[/TD]
[TD]4[/TD]
[TD]5[/TD]
[TD]6
[/TD]
[/TR]
</tbody>[/TABLE]

In this case, each of the values in the table are based on formulas in other worksheets.
I would like to have a macro to transpose this database (in this same worksheet or a new worksheet) to the following format:

[TABLE="width: 192"]
<colgroup><col width="64" span="3" style="width:48pt"> </colgroup><tbody>[TR]
[TD="class: xl66, width: 64"]Year[/TD]
[TD="class: xl66, width: 64"]Country[/TD]
[TD="class: xl66, width: 64"]Value[/TD]
[/TR]
[TR]
[TD="class: xl66"]2010[/TD]
[TD="class: xl66"]China[/TD]
[TD="class: xl66"]1[/TD]
[/TR]
[TR]
[TD="class: xl66"]2011[/TD]
[TD="class: xl66"]China[/TD]
[TD="class: xl66"]2[/TD]
[/TR]
[TR]
[TD="class: xl66"]2012[/TD]
[TD="class: xl66"]China[/TD]
[TD="class: xl66"]3[/TD]
[/TR]
[TR]
[TD="class: xl66"]2013[/TD]
[TD="class: xl66"]China[/TD]
[TD="class: xl66"]4[/TD]
[/TR]
[TR]
[TD="class: xl66"]2010[/TD]
[TD="class: xl66"]US[/TD]
[TD="class: xl66"]2[/TD]
[/TR]
[TR]
[TD="class: xl66"]2011[/TD]
[TD="class: xl66"]US[/TD]
[TD="class: xl66"]3[/TD]
[/TR]
[TR]
[TD="class: xl66"]2012[/TD]
[TD="class: xl66"]US[/TD]
[TD="class: xl66"]4[/TD]
[/TR]
[TR]
[TD="class: xl66"]2013[/TD]
[TD="class: xl66"]US[/TD]
[TD="class: xl66"]5[/TD]
[/TR]
[TR]
[TD="class: xl66"]2010[/TD]
[TD="class: xl66"]EU[/TD]
[TD="class: xl66"]3[/TD]
[/TR]
[TR]
[TD="class: xl66"]2011[/TD]
[TD="class: xl66"]EU[/TD]
[TD="class: xl66"]4[/TD]
[/TR]
[TR]
[TD="class: xl66"]2012[/TD]
[TD="class: xl66"]EU[/TD]
[TD="class: xl66"]5[/TD]
[/TR]
[TR]
[TD="class: xl66"]2013[/TD]
[TD="class: xl66"]EU[/TD]
[TD="class: xl66"]6[/TD]
[/TR]
</tbody>[/TABLE]

In this case, the exact formulas have to transfer as well. This is crucial.

In addition, the macro should work regardless of the number of columns and rows in the initial database (sometimes the time period is 1961-2013 and I have as many as 100 countries).

Any suggestions?
Much appreciated!
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.

Forum statistics

Threads
1,223,911
Messages
6,175,325
Members
452,635
Latest member
laura12345

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top