Macro to extract and transpose data from multiple tabs into a single sheet

thatexcelguy91

New Member
Joined
Jan 31, 2018
Messages
1
Hi,

I have a workbook that contains data for ~200 companies in different tabs in the same format. The format has all the years in a single row at the top, with multiple columns eg 2010,2011...2016. Also there are metrics listed in single column (first one,extreme left) eg revenue, cost etc in a single column in different rows.

I intend to create a macro which can create a flat file structured tab which essentially aggregates data from all the tabs into a single tab. The format should be such that the metrics and years are transposed. Eg the metrics are listed at the top in a single row,multiple columns. Then all the companies are shown from the latest year, with 2016 year shown for all the companies first, then 2015 for all...and so on.

So far have only been able to create the below, any help would be great:

Sub CreateFlatFile()
Dim wb As Workbook, sh As Worksheet, shname As String, i As Integer
i = 251
For Each sh In ActiveWorkbook.Worksheets
If sh.Name Like "Company 1*" Then
sh.Activate
Cells(i, 21).Resize(1, 300).Copy
Worksheets("DataforTableau").Select
Cells(2, 21).PasteSpecial Transpose:=True
End If
Next sh
End Sub
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".

Forum statistics

Threads
1,223,948
Messages
6,175,566
Members
452,652
Latest member
eduedu

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