Sub Macro1()
‘ Macro1 Macro
‘ 快捷键: Ctrl+Shift+A
    Application.Goto Reference:="Macro1"
    Application.DisplayAlerts = False
    For i = [a65536].End(3).Row To 2 Step -1
        If Cells(i - 1, 1) = Cells(i, 1) Then
            Range(Cells(i - 1, 1), Cells(i, 1)).Merge
        End If
    Next
   For i = [a65536].End(3).Row To 2 Step -1
        If Cells(i - 1, 7) = Cells(i, 7) Then
            Range(Cells(i - 1, 7), Cells(i, 7)).Merge
        End If
    Next
    Application.DisplayAlerts = True
End Sub
原文:http://www.cnblogs.com/51yi/p/7606213.html