Merge Cells & Unmerge Cells in Excel VBA

In this post, you’ll learn how to Merge cells and Unmerge cells in Excel VBA and apply them in your Excel workbook.

Merge Cells and Unmerge Cells in Excel VBA

You can use .merge and .unmerge commands to merge and unmerge cells in your spreadsheets using excel VBA . The following operations can be done using the commands.

  • Merge Cells using VBA
  • Unmerge Cells using VBA
  • Merge Rows using VBA
  • Merge Columns using VBA

Merge Cells Using VBA

To merge cells using VBA, use the Range.Merge method.

Code:

Sub MergeCells()
Range("A1:D1").Merge
End Sub
Merge Cells and Unmerge Cells in Excel VBA

Unmerge Cells Using VBA

To merge cells using VBA, use the Range.UnMerge method.

Code:

Sub UnmergeCells()
Range("C1").UnMerge
End Sub
Merge Cells and Unmerge Cells in Excel VBA

Merge Rows Using VBA

To merge rows using VBA,

Code:

Sub MergeRows()
Range("1:5").Merge
End Sub
Merge Cells and Unmerge Cells in Excel VBA

Merge Columns Using VBA

To merge columns using VBA,

Code:

Sub MergeColumns()
Range("A:C").Merge
End Sub
Merge Cells and Unmerge Cells in Excel VBA
Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Hey, wait!Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.