首页 > Excel专区 > Excel教程 >

excel撤销合并单元格并填充相应内容的宏

Excel教程 2021-06-25 22:08:42

1、按快捷键Alt+F11,打开VBA编辑器。在“工程”窗口中双击选择包含合并单元格的工作表,在右侧的代码窗口中粘贴下列代码:

Private Sub kbiji()
Dim i As Range
For Each i In ActiveSheet.UsedRange
If i.Address <> i.MergeArea.Address And i.Address = i.MergeArea.Item(1).Address Then
i.MergeArea.Select
i.MergeArea.UnMerge
Selection.FillDown
End If
Next i
End Sub


2、将光标定位到代码中,单击工具栏中的“运行子过程/用户窗体”按钮或按F5键运行代码,当前工作表中的合并单元格都将被解除合并。



标签: excel撤销合并单元格

office教学网 Copyright © 2016-2021 office.mshxw.com. Some Rights Reserved. 备案号:晋ICP备2021003244-6号