Try this:
Sub sboivin(): Dim r As Long, c As Long, s As Long, P, Q
Dim w1 As Worksheet, w2 As Worksheet: s = 1
Set w1 = Sheets("Sheet1"): Set w2 = Sheets("Sheet2")
w2.Cells.ClearContents: P = w1.UsedRange
Q = w2.Cells(1, 1).Resize((UBound(P, 1) - 5) * UBound(P, 2), 3)
Q(1, 1) = "Value": Q(1, 2) = "Column Header": Q(1, 3) = "Line Header"
For r = 6 To UBound(P, 1): For c = 2 To UBound(P, 2)
If P(r, c) <> 0 Then
s = s + 1: Q(s, 1) = P(r, c): Q(s, 2) = P(5, c): Q(s, 3) = P(r, 1)
End If: Next c: Next r
w2.Cells(1, 1).Resize(s, 3) = Q
w2.UsedRange.Borders.Weight = xlMedium
End Sub
and let me know
BTW - I moved your sheet 1 sample down a row to start in B6.
Bookmarks