Skip to content

Instantly share code, notes, and snippets.

@gouf
Forked from kos59125/Unmerge.bas
Last active September 4, 2015 04:55
Show Gist options
  • Save gouf/99b7947f6b7f187363c1 to your computer and use it in GitHub Desktop.
Save gouf/99b7947f6b7f187363c1 to your computer and use it in GitHub Desktop.
アクティブシートの結合されたセルの結合を解除して,すべてのセルの値を結合元のセルの値で埋めます。
Option Explicit
' アクティブシートの結合されたセルの結合を解除して,すべてのセルの値を結合元のセルの値で埋めます。
Public Sub Unmerge()
Dim OuterCell As Variant
Dim InnerCell As Variant
Dim Value As Variant
Dim Updating As Boolean ' 現在のスクリーン更新状態
Updating = Application.ScreenUpdating
' スクリーン更新停止
Application.ScreenUpdating = False
For Each OuterCell In ActiveSheet.UsedRange
Value = OuterCell.Value
For Each InnerCell In OuterCell.MergeArea
InnerCell.MergeCells = False
InnerCell.Value = Value
Next InnerCell
Next OuterCell
' スクリーン更新状態を元に戻す
Application.ScreenUpdating = Updating
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment