Here is the macro for the benefit of other readers...
Sub Transpose()
Dim lastRow, lastCol As Long
Dim srcSheet As String
Dim destSheet As String
Dim i, j, k As Long
Dim RM() As String
Application.ScreenUpdating = False
srcSheet = "BOM (Bill of materials)"
destSheet = ActiveSheet.Name
Worksheets(srcSheet).Activate
With Worksheets(srcSheet)
lastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
lastCol = .Cells(1, .Columns.Count).End(xlToLeft).Column
End With
ReDim RM(lastCol)
For j = 3 To lastCol
RM(j) = Worksheets(srcSheet).Cells(1, j)
Next
k = 2
For i = 2 To lastRow
Sheets(destSheet).Cells(k, 1) = Worksheets(srcSheet).Cells(i, 1)
Sheets(destSheet).Cells(k, 2) = Worksheets(srcSheet).Cells(i, 2)
For j = 3 To lastCol
If (Worksheets(srcSheet).Cells(i, j) <> "") Then
Sheets(destSheet).Cells(k, 3) = RM(j)
Sheets(destSheet).Cells(k, 4) = Worksheets(srcSheet).Cells(i, j)
k = k + 1
End If
Next j
Next i
Worksheets(destSheet).Activate
Application.ScreenUpdating = True
End Sub
Sub clearCells()
With ActiveSheet
lastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
lastCol = .Cells(1, .Columns.Count).End(xlToLeft).Column
End With
Range(Cells(2, 1), Cells(lastRow, lastCol)).clear
End Sub