Sub a()
Dim iRow As Long, i As Long, lastRow As Long
Dim str As String, arr As Variant
Application.ScreenUpdating = False
iRow = Range("A60000").End(xlUp).Row
lastRow = Range("B60000").End(xlUp).Row + 1
For i = 2 To iRow
If InStr(Cells(i, 1), "公司") > 0 Then
str = str & i & ","
End If
Next
arr = Split(Left(str, Len(str) - 1), ",")
For i = 0 To UBound(arr)
If i < UBound(arr) Then
Range("A" & arr(i), "A" & arr(i + 1) - 1).Copy
Range("B" & lastRow).PasteSpecial Transpose:=True
lastRow = Range("B60000").End(xlUp).Row + 1
Else
Range("A" & arr(i), "A" & iRow).Copy
Range("B" & lastRow).PasteSpecial Transpose:=True
End If
Next
Application.CutCopyMode = False
Application.ScreenUpdating = True
End Sub
应该有更简便的循环方式,暂时先用上面这个吧。