合并单元格拆分,并把第一个单元格的值赋给所有被合并单元格
Posted Sundance8866
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了合并单元格拆分,并把第一个单元格的值赋给所有被合并单元格相关的知识,希望对你有一定的参考价值。
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
以上是关于合并单元格拆分,并把第一个单元格的值赋给所有被合并单元格的主要内容,如果未能解决你的问题,请参考以下文章