Sub 合并单元格() '对选取的单元进行相同项合并 Application.ScreenUpdating = False Application.DisplayAlerts = False On Error Resume Next With Selection For I = .Count To 1 Step -1 If .Cells(I) = .Cells(I - 1) And .Cells(I) <> "" Then Range(.Cells(I), .Cells(I - 1)).Merge End If Next I .VerticalAlignment = xlCenter '上下居中 End With Application.DisplayAlerts = True Application.ScreenUpdating = True End Sub