Here's a VBA solution.
Assumes source data is in cols A:C starting at A1
Execute the "rearrange" macro.
The re-arranged data starts at E1
See the attached workbook
Here's the VBA:
'Reorganize imported data
'Consolidate row data when the name in column-A is blank
'Assume columns A:C starting at A1 contains the imported data
'Assume the output data starts at cell E1
Sub rearrange()
Dim OutRng As Range, InRng As Range
Dim inrow As Integer, outrow As Integer 'input and output row counters
Set InRng = ActiveSheet.Range("A1")
Set OutRng = ActiveSheet.Range("E1")
inrow = 1
outrow = 1
'loop around all imported data
While inrow <= ActiveSheet.UsedRange.Rows.Count
OutRng.Cells(outrow, 1) = InRng.Cells(inrow, 1)
OutRng.Cells(outrow, 2) = InRng.Cells(inrow, 2)
OutRng.Cells(outrow, 3) = InRng.Cells(inrow, 3)
inrow = inrow + 1
'If the name column is blank then append data to the same output row
If (IsEmpty(InRng.Cells(inrow, 1))) Then
OutRng.Cells(outrow, 4) = InRng.Cells(inrow, 2)
OutRng.Cells(outrow, 5) = InRng.Cells(inrow, 3)
inrow = inrow + 1
End If
'A second blank name row - append data to the same output row
If (IsEmpty(InRng.Cells(inrow, 1))) Then
OutRng.Cells(outrow, 6) = InRng.Cells(inrow, 2)
OutRng.Cells(outrow, 7) = InRng.Cells(inrow, 3)
inrow = inrow + 1
End If
outrow = outrow + 1
Wend
End Sub
Bookmarks