Re: Transpose Data From Horizontal To Vertical
This is great. i
had similar problem and this macro worked like a charm.
many thanks
Quote from MickG;786201Try this for results on sheet2:-
CodeDisplay MoreSub Trans() Dim Ray As Variant, c As Long, n As Long, ac As Long Ray = Range("B5").CurrentRegion ReDim nRay(1 To UBound(Ray, 1) * (UBound(Ray, 2) - 3), 1 To 5) nRay(1, 1) = "Project No": nRay(1, 2) = "Code": nRay(1, 3) = "Employee Name" nRay(1, 4) = "Week Ending": nRay(1, 5) = "Hours" c = 1 For n = 2 To UBound(Ray, 1) For ac = 4 To UBound(Ray, 2) c = c + 1 nRay(c, 1) = Ray(n, 1): nRay(c, 2) = Ray(n, 2): nRay(c, 3) = Ray(n, 3) nRay(c, 4) = Ray(1, ac): nRay(c, 5) = Ray(n, ac) Next ac Next n With Sheets("Sheet2").Range("A1").Resize(c, 5) .Value = nRay .Borders.Weight = 2 .Columns.AutoFit End With End Sub
Regards Mick