Excel宏开发之合并单元格
Posted miaosj
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Excel宏开发之合并单元格相关的知识,希望对你有一定的参考价值。
合并单元格
Sub 宏1() ‘ ‘ 宏1 宏 ‘ ‘ 快捷键: Ctrl+q ‘ Application.Goto Reference:="宏1" Application.VBE.MainWindow.Visible = True Application.DisplayAlerts = False For i = [A65536].End(3).Row To 2 Step -1 If Cells(i - 1, 1) = Cells(i, 1) Then Cells(i - 1, 1).HorizontalAlignment = xlCenter Cells(i - 1, 1).VerticalAlignment = xlCenter Range(Cells(i - 1, 1), Cells(i, 1)).Merge End If Next For i = [B65536].End(3).Row To 2 Step -1 If Cells(i - 1, 2) = Cells(i, 2) Then Cells(i - 1, 2).HorizontalAlignment = xlCenter Cells(i - 1, 2).VerticalAlignment = xlCenter Range(Cells(i - 1, 2), Cells(i, 2)).Merge End If Next For i = [C65536].End(3).Row To 2 Step -1 If Cells(i - 1, 3) = Cells(i, 3) Then If Cells(i - 1, 2) = Cells(i, 2) Then Cells(i - 1, 3).HorizontalAlignment = xlCenter Cells(i - 1, 3).VerticalAlignment = xlCenter Range(Cells(i - 1, 3), Cells(i, 3)).Merge End If End If Next Application.DisplayAlerts = True Application.VBE.MainWindow.Visible = False End Sub
以上是关于Excel宏开发之合并单元格的主要内容,如果未能解决你的问题,请参考以下文章