Hi,
Here is your code... you can run it by pressing Ctr + Shift + K
Option Explicit
Sub TransposeMetricData()
Dim I As Integer, j As Integer, k As Integer
Dim Headrng As Range
Dim Monthrng As Range
Dim TotalRecords As Integer
Dim LastRow As Integer
Dim Filldown As Integer
Dim Sh1 As Worksheet, Sh2 As Worksheet
With Application
.ScreenUpdating = False
.CutCopyMode = False
End With
Set Sh1 = ThisWorkbook.Sheets(1)
Set Sh2 = ThisWorkbook.Sheets(2)
Set Headrng = Sh1.Range("A1:F1")
Set Monthrng = Sh1.Range("G1:BT1")
TotalRecords = Sh1.Range("A80000").End(xlUp).Row - 1
Sh2.Activate
Headrng.Copy Range("A1")
Range("G1:H1") = Array("Timeframe", "Data")
For I = 1 To TotalRecords
LastRow = Range("A80000").End(xlUp).Row + 1
Headrng.Offset(I, 0).Copy Sh2.Range("a" & LastRow)
Monthrng.Copy
Sh2.Range("G" & LastRow).PasteSpecial Transpose:=True
Monthrng.Offset(1, 0).Copy
Sh2.Range("H" & LastRow).PasteSpecial Transpose:=True
Filldown = Range("H80000").End(xlUp).Row
Range("A" & LastRow, Range("F" & Filldown)).Select
Selection.Filldown
Next I
Columns("A:H").AutoFit
Msgbox "Done!"
With Application
.ScreenUpdating = True
.CutCopyMode = True
End With
End Sub
Here is your attachment...Sample.xlsm
Cheers.....
If your question is resolved, mark it SOLVED using the thread tools. Click on the star if you think some-1 helped you.
Bookmarks