Found the error.
Note: I think your Output Data 1 sheet, row 5, is incorrect so I ignored it.
Sub GMATH()
Dim ws As Worksheet: Set ws = Sheets("Input Data")
Dim wsOut As Worksheet: Set wsOut = Sheets("Output Data")
Dim c As Range, rng As Range
Dim LR As Long
Application.ScreenUpdating = False
For Each c In ws.Range("A2:A" & ws.Range("A" & Rows.Count).End(xlUp).Row)
If Len(c) <> 0 Then
Set rng = c.Resize(1, 3)
LR = wsOut.Range("A" & Rows.Count).End(xlUp).Offset(1).Row
If Len(c.Offset(, 3)) = 0 Then
wsOut.Range("A" & LR).Resize(1, 3).Value = rng.Value
Else
wsOut.Range("A" & LR).Resize(1, 3).Value = rng.Value
ws.Range(ws.Cells(c.Row, 4), ws.Cells(c.Row, ws.Cells(c.Row, Columns.Count).End(xlToLeft).Column)).Copy
wsOut.Range("D" & LR).PasteSpecial xlPasteValues, , , True
If Len(c.Offset(, 4)) <> 0 Then wsOut.Range("A" & LR).Resize(wsOut.Range("D" & Rows.Count).End(xlUp).Row - LR + 1, 3).FillDown
End If
End If
Next c
Application.ScreenUpdating = True
End Sub
Bookmarks