HomeMicrosoft OfficeExcelMerge Cells & Unmerge Cells in Excel VBA

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 article, you will learn about the SKEW.P function, the formula syntax and usage of the function in Microsoft...
In this article, you will learn about the SKEW function, the formula syntax and usage of the function in Microsoft...
In this article, you will learn about the RANK.EQ function, the formula syntax and usage of the function in Microsoft...
  • Excel
  • November 23, 2021