Last active
December 11, 2018 16:46
-
-
Save haruo31/c753015e2da84f7745dbe1a64dbf0fd5 to your computer and use it in GitHub Desktop.
The Excel VBA script un-merge cells and copy contents to them. It runs on current worksheet. - Excelの開いているシートにある全ての結合セルを分解し、それぞれに内容をコピーするVBA
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Option Explicit | |
Sub breakUpMergedCells() | |
Dim curSheet As Worksheet | |
Dim eCell As Range, curRange As Range | |
Dim curAddr As String | |
Dim fillCell As Range | |
Dim filledValue As String | |
Set curSheet = ActiveSheet | |
Set eCell = curSheet.Cells.SpecialCells(xlCellTypeLastCell) | |
For Each curRange In curSheet.Range(curSheet.Range("A1"), eCell) | |
If curRange.MergeCells Then | |
curAddr = curRange.MergeArea.Address | |
filledValue = curRange.Formula | |
curRange.UnMerge | |
For Each fillCell In curSheet.Range(curAddr) | |
fillCell.Formula = filledValue | |
Next | |
End If | |
Next | |
End Sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment