Sub 合并整列单元格() Dim i As Integer Application.DisplayAlerts = False ' w = InputBox("请输入 数字列号(比如1,2,3代表列数)") For i = Cells(Rows.Count, Val(w)).End(xlUp).Row To 2 Step -1 If Cells(i, Val(w)).Value = Cells(i, Val(w))(0, 1).Value Then Cells(i, Val(w))(0, 1).Resize(2, 1).Merge End If Next Application.DisplayAlerts = True End Sub |
|
来自: 随心所欲2019OK > 《excel-VBA》