答案 0 :(得分:0)
尝试一下...
Option Explicit
Public Sub Group()
Dim rng As Range
Dim LastRow As Long
Dim RowsInRange As Long
Dim i As Long
With ThisWorkbook.Sheets("Sheet1")
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
End With
For i = 4 To LastRow
Do While ThisWorkbook.Sheets("Sheet1").Cells(i, 1) = ThisWorkbook.Sheets("Sheet1").Cells(i + 1, 1)
RowsInRange = RowsInRange + 1
i = i + 1
Loop
ThisWorkbook.Sheets("Sheet1").Cells(i - RowsInRange, 1).Font.Bold = True
Set rng = Range(Cells(i - RowsInRange + 1, 1), Cells(i, 1))
rng.Select
Selection.Rows.Group
RowsInRange = 0
Next
End Sub