首页 > 其他 > 详细

合并单元格拆分,并把第一个单元格的值赋给所有被合并单元格

时间:2020-03-20 12:56:03      阅读:48      评论:0      收藏:0      [点我收藏+]
Sub unmergeRange()
Dim rg As Range
With ActiveSheet
    Set rg = .UsedRange
    rowmax = rg.Rows.Count
    columnmax = rg.Columns.Count
    For i = 2 To rowmax
        For j = 1 To columnmax
            If .Cells(i, j).MergeCells Then
                Call UnMergeFunction(.Cells(i, j).MergeArea)
            End If
        Next
    Next
End With
MsgBox "OK"
End Sub

Sub UnMergeFunction(ra As Range)unmerge the merged range, input the first value into all the merged cells
With ra
    aaa = .Cells(1).Value
    .unmerge
    For Each Ce In .Cells
        Ce.Value = aaa
    Next
End With
End Sub

 

合并单元格拆分,并把第一个单元格的值赋给所有被合并单元格

原文:https://www.cnblogs.com/sundanceS/p/12529974.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!