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

Leave A Reply

Your email address will not be published. Required fields are marked *

You May Also Like

In this post, you’ll learn how to Find Blank cells in excel so that you can remove or delete the blank cells form...
In this article, you’ll learn what is a Gauge Chart in Microsoft Excel. Also, you will learn how to add...
Microsoft Excel provides a shortcut for the users to move columns in excel using two different ways – using Shift...