Excel Vba拆分并填充单元格

https://www.cnblogs.com/icedream/archive/2013/03/05/2945158.html

Sub 拆分并填充单元格()
'
' 拆分并填充单元格 宏
'
' 可以将选中的所有单元格都拆开并填充
'
    If Application.Selection.MergeCells = True Then
        Set selectedRange = Application.Selection
        selectedRange.UnMerge
        selectedRange.Value = selectedRange.Cells(1, 1).Value
    Else
        For Each selectedCell In Application.Selection
            If selectedCell.MergeCells = True Then
                Set selectedRange = selectedCell.MergeArea
                selectedRange.UnMerge
                selectedRange.Value = selectedRange.Cells(1, 1).Value
            End If
        Next
    End If
End Sub

记录一下,免得每次都找。

你可能感兴趣的:(Excel,Excel,拆分合并单元格)