Hi,
The following macro should work. It will put the results starting in column G of the Final Re Arranged sheet so that you can compare with your manual example. With the production environment data obviously change the G1 reference in the macro to A1 or wherever you want the table.
Sub ReOrderData()
Dim lRow As Long, lColumns As Long, stComp As String, dt As Date, lCount As Long
For lRow = 3 To Sheet1.Range("A1").CurrentRegion.Rows.Count
If LCase(Sheet1.Range("A1").Cells(lRow, 3)) = "yes" Then
stComp = Sheet1.Range("A1").Cells(lRow, 1)
dt = Sheet1.Range("A1").Cells(lRow, 2)
For lColumns = 1 To (Sheet1.Range("A1").Cells(lRow, Columns.Count).End(xlToLeft).Column - 3) / 2
Sheet2.Range("G1").Cells(lRow + lCount, 1) = stComp
Sheet2.Range("G1").Cells(lRow + lCount, 2) = dt
Sheet2.Range("G1").Cells(lRow + lCount, 3) = "yes"
Sheet2.Range("G1").Cells(lRow + lCount, 4) = Sheet1.Range("A1").Cells(lRow, lColumns * 2 + 2)
Sheet2.Range("G1").Cells(lRow + lCount, 5) = Sheet1.Range("A1").Cells(lRow, lColumns * 2 + 3)
lCount = lCount + 1
Next lColumns
End If
lCount = lCount - 1
Next lRow
End Sub
Bookmarks