I'm assuming your data starts from Cell A1.
Just add a row with hyphens to mark the end of the data sheet like;
A |
1 |
Event 1 |
|
|
Event 2 |
|
|
Event 3 |
B |
2 |
Group 1 |
|
|
Group 2 |
- |
- |
- |
Then run the following macro: (Your results will be displayed in Sheet 2)
Sub SmartTranspose()
j = 1
For nRow = 1 To Sheets(1).UsedRange.Count
If nRow = 1 Then
sCategory = Cells(nRow, 1).Value
sSubCategory = Cells(nRow, 2).Value
sItem = Cells(nRow, 3).Value
Else
If Cells(nRow, 2).Value = "" Then
sItem = sItem & ";" & Cells(nRow, 3).Value
Else
aItem = Split(sItem, ";")
Sheets(2).Cells(j, 1) = sCategory
Sheets(2).Cells(j, 2) = sSubCategory
c = 3
For x = 0 To UBound(aItem)
Sheets(2).Cells(j, c) = aItem(x)
c = c + 1
Next
sCategory = Cells(nRow, 1).Value
sSubCategory = Cells(nRow, 2).Value
sItem = Cells(nRow, 3).Value
j = j + 1
End If
End If
Next
End Sub
Bookmarks