
正文
Excel宏开发之合并单元格
提示:扫一扫查出行【扫一扫了解最新限行尾号】
复制提示
合并单元格
Sub 宏1()
'
' 宏1 宏
'
' 快捷键: Ctrl+q
'
Application.Goto Reference:="宏1"
Application.VBE.MainWindow.Visible = True Application.DisplayAlerts = False For i = [A65536].End().Row To Step -
If Cells(i - , ) = Cells(i, ) Then
Cells(i - , ).HorizontalAlignment = xlCenter
Cells(i - , ).VerticalAlignment = xlCenter
Range(Cells(i - , ), Cells(i, )).Merge
End If
Next For i = [B65536].End().Row To Step -
If Cells(i - , ) = Cells(i, ) Then
flag = True
If (Cells(i, ) <> "") Then
flag = False
End If
If flag Then
Cells(i - , ).HorizontalAlignment = xlCenter
Cells(i - , ).VerticalAlignment = xlCenter
Range(Cells(i - , ), Cells(i, )).Merge
End If
End If
Next For i = [C65536].End().Row To Step -
If Cells(i - , ) = Cells(i, ) Then
flag = True
If (Cells(i, ) <> "") Then
flag = False
End If
If flag Then
Cells(i - , ).HorizontalAlignment = xlCenter
Cells(i - , ).VerticalAlignment = xlCenter
Range(Cells(i - , ), Cells(i, )).Merge
End If End If
Next Application.DisplayAlerts = True Application.VBE.MainWindow.Visible = False
End Sub







