Option Explicit
Sub ABC()
Dim i&, j&, Lr&, t&, k&, d&, R&, Length&, A&
Dim Arr(), KQ()
Dim Sh As Worksheet, Ws As Worksheet
Set Sh = Sheets("Detail")
Lr = Sh.Cells(Rows.Count, 13).End(xlUp).Row
Arr = Sh.Range("A6:P" & Lr).Value
R = UBound(Arr)
ReDim KQ(1 To R, 1 To 9)
For i = 1 To R
If Arr(i, 1) <> Empty Then
If Not IsNumeric(Mid(Arr(i, 1), 2, 1)) Then
j = j + 1: A = A + 1
KQ(j, 1) = Application.WorksheetFunction.Roman(A)
KQ(j, 2) = Arr(i, 1)
End If
If IsNumeric(Mid(Arr(i, 1), 1, 2)) Then
t = t + 1: j = j + 1: d = 0: Length = 0: k = i
d = Sh.Cells(i + 5, 13).End(xlDown).Row - 5
KQ(j, 1) = t
KQ(j, 2) = Arr(i, 1)
KQ(j, 3) = Arr(i, 2)
KQ(j, 4) = Arr(i, 3)
For k = i To d
If Arr(k, 7) <> Empty And IsNumeric(Arr(k, 7)) And Arr(k, 7) >= Length Then Length = Arr(k, 7): KQ(t, 5) = Length
Next k
For k = i To d
If Arr(k, 16) <> Empty Then KQ(j, 9) = Arr(k, 16): Exit For
Next k
KQ(j, 6) = Arr(d, 13)
KQ(j, 7) = Arr(d, 14)
KQ(j, 8) = Arr(d, 15)
End If
End If
Next i
Set Ws = Sheets("Summary List")
If t Then
Ws.Range("B4").Resize(50000, 9).Clear
Ws.Range("B4").Resize(j, 9) = KQ
Ws.Range("B4").Resize(j, 9).Borders.LineStyle = 1
End If
MsgBox "Done"
End Sub