This updated page also has the VBA solution that arrives at the same solution. In this case VBA creates an output sheet. This update contains both solutions.
Option Explicit
Sub CONVERTROWSTOCOL2()
Dim rsht1 As Long, rsht2 As Long, i As Long, col As Long, wsTest As Worksheet, mr As Worksheet, ms As Worksheet
'check if sheet "ouput" already exist
Const strSheetName As String = "Output"
Set wsTest = Nothing
On Error Resume Next
Set wsTest = ActiveWorkbook.Worksheets(strSheetName)
On Error GoTo 0
If wsTest Is Nothing Then
Worksheets.Add.Name = strSheetName
End If
'set the data
Set mr = Sheet2 'this is the name of the source sheet
Set ms = Sheets("Output") 'this is the name of the destiny sheet
col = 2
'End set the data
With ms
.UsedRange.ClearContents
.Range("A1:C1").Value = Array("Name", "Class", "value")
End With
rsht2 = ms.Range("A" & Rows.Count).End(xlUp).Row
With mr
rsht1 = .Range("A" & .Rows.Count).End(xlUp).Row
For i = 2 To rsht1
Do While .Cells(1, col).Value <> ""
rsht2 = rsht2 + 1
ms.Range("A" & rsht2).Value = .Range("A" & i).Value
ms.Range("B" & rsht2).Value = .Cells(1, col).Value
ms.Range("C" & rsht2).Value = .Cells(i, col).Value
col = col + 1
Loop
col = 2
Next
End With
With ms
.Range("C2:C" & .Rows.Count).SpecialCells(4).EntireRow.Delete
.Columns("A:C").EntireColumn.AutoFit
End With
End Sub
Bookmarks