Public Sub ExtractData()
Dim wsRes As Worksheet
Dim nextrow As Long
Dim lastrow As Long
Dim i As Long
On Error Resume Next
Application.DisplayAlerts = False
Worksheets("Output").Delete
Application.DisplayAlerts = True
On Error GoTo 0
With ActiveSheet
Set wsRes = Worksheets.Add(after:=Worksheets(Worksheets.Count))
wsRes.Name = "Output"
wsRes.Range("A1:E1").Value = Array("Id", "Red", "Blue", "Green", "Yellow")
nextrow = 1
lastrow = .Cells(.Rows.Count, "B").End(xlUp).Row
For i = 2 To lastrow
If Not .Cells(i, "B").Value = vbNullString Then
nextrow = nextrow + 1
.Cells(i, "B").Copy wsRes.Cells(nextrow, "A")
End If
.Cells(i, "E").Copy wsRes.Cells(nextrow, wsRes.Cells(nextrow, wsRes.Columns.Count).End(xlToLeft).Column + 1)
Next i
End With
End Sub