第1个回答 2020-01-17
Sub
合并()
Application.DisplayAlerts
=
False
Set
tt
=
Selection
a
=
tt.Rows.Count
x
=
tt.Row
y
=
tt.Column
s
=
tt.Columns.Count
-
1
For
j
=
x
To
x
+
a
-
1
For
i
=
1
To
s
Cells(j,
y)
=
Cells(j,
y)
&
Cells(j,
y
+
i)
Next
Range(Cells(j,
y),
Cells(j,
y
+
s)).Merge
Next
Application.DisplayAlerts
=
True
End
Sub
在表中按下面标签,右键“查看代码”,然后将上面代码复制到出现的窗口中,回到EXCEL窗口。先把要合并的单元格全部选中,在“工具-宏-宏”中,执行“合并”宏即可。