贴吧里边找的。温柔小兔写的,没试过。
http://tieba.baidu.com/p/2488583858Sub 合并单元格()
a = Selection.Column
Columns(a + 1).Insert
For i = 1 To Cells(65536, a).End(xlUp).Row
If i = 1 Then m = 1
If Cells(i, a) <> Cells(i + 1, a) Or Len(Cells(i, a)) <> Len(Cells(i + 1, a)) Then
Range(Cells(m, a + 1), Cells(i, a + 1)).Merge
m = i + 1
End If
Next
Columns(a + 1).Copy
Columns(a).PasteSpecial Paste:=xlPasteFormats
Columns(a + 1).Delete
End Sub