右键点 工作表 标签, 查看代码, 把如下复制进去 ,F5运行
Sub hebing()
j = 1
For i = 2 To Range("A65536").End(xlUp).Row
If Cells(i, 1) <> Cells(j, 1) Then
j = i
Else
Application.DisplayAlerts = False
Range(Cells(j, 1), Cells(i, 1)).Merge
Application.DisplayAlerts = True
End If
Next
End Sub
用VBA解决。
你可以私信我帮你编写一个宏来解决。
写好了:
Sub cs()
Application.DisplayAlerts = False
Application.ScreenUpdating = False
With ActiveSheet
r = .Cells(Rows.Count, 1).End(xlUp).Row
Set Rng = .[a2]
For i = 3 To r
If .Cells(i, 1) = .Cells(i - 1, 1).Value Then
Set Rng = Union(Rng, .Cells(i, 1))
Else
If Rng.Count > 1 Then Rng.Merge
Set Rng = .Cells(i, 1)
End If
Next
End With
End Sub