With so much data, I felt the process would execute more rapidly, as Jeeped mentioned, done in VBA arrays instead of on the worksheet. Here is a macro that does that. To tell where to start a new row, I looked at column 2 -- if column 2 is blank, then the data is appended to the previous row; if not, then a new row would start.
Other types of testing could be substituted.
Option Explicit
Sub TransposeSomeRows()
Dim wsSrc As Worksheet, wsRes As Worksheet, rRes As Range
Dim vSrc As Variant, vRes() As Variant
Dim I As Long, J As Long, K As Long
Dim lRowCount As Long, lColCount As Long
Set wsSrc = Worksheets("sheet1")
Set wsRes = Worksheets("sheet2")
Set rRes = wsRes.Cells(1, 1)
With wsSrc.Cells
lRowCount = .Find(what:="*", after:=.Item(1, 1), LookIn:=xlValues, _
searchorder:=xlByRows, searchdirection:=xlPrevious).Row
lColCount = .Find(what:="*", after:=.Item(1, 1), _
searchorder:=xlByColumns, searchdirection:=xlPrevious).Column
End With
'Read source data into array
With wsSrc
vSrc = .Range(.Cells(2, 1), .Cells(lRowCount, lColCount))
End With
'create results array
'Num of rows = number of items in Column 2
lRowCount = WorksheetFunction.CountA(wsSrc.Columns(2))
'Num of columns = max of entries in a "start row" plus blanks to next "start row"
lColCount = 0
For I = 1 To UBound(vSrc, 1)
If vSrc(I, 2) <> "" Then
For J = 1 To UBound(vSrc, 2)
If vSrc(I, J) <> "" Then K = J
Next J
Else 'vSrc(i,2) = "" so add a column
K = K + 1
End If
lColCount = IIf(lColCount > K, lColCount, K)
Next I
ReDim vRes(1 To lRowCount, 1 To lColCount)
'Populate results array
K = 0
For I = 1 To UBound(vSrc, 1)
If vSrc(I, 2) <> "" Then
K = K + 1
J = 1
For J = 1 To UBound(vSrc, 2)
If vSrc(I, J) <> "" Then
vRes(K, J) = vSrc(I, J)
Else
Exit For
End If
Next J
Else
vRes(K, J) = vSrc(I, 1)
J = J + 1
End If
Next I
'Write results to worksheet
Set rRes = rRes.Resize(UBound(vRes, 1), UBound(vRes, 2))
With rRes
.EntireColumn.Clear
.Value = vRes
.EntireColumn.AutoFit
End With
End Sub