VBA Code to Unmerge all Merged Cells in an Excel Worksheet

VBA Code to Unmerge all Merged Cells in an Excel Worksheet

We often come across merged cells in Microsoft Excel which is the integration of two or more cells in adjacent columns, rows, or both. It’s a common practice to merge cells in Excel but may require unmerging in certain cases, for example – when the data needs to be sorted. The cells can be unmerged by selecting the merged cell and clicking on “Merge and Center” in the Alignment group on the Home tab. However, if there are multiple such cases in a worksheet and you want to save time, use the following VBA code to unmerge all merged cells at one go.

Copy the below code

'ExcelJunction.com - VBA Code to Unmerge all Merged Cells in an Excel Worksheet at one go
Sub UnmergeAllCells()
ActiveSheet.Cells.UnMerge
End Sub

 

Unmerge all Merged Cells