Hello Excellers and welcome to some more #macromonday fun. Today let’s look at how to use Excel VBA macro to un-merge cells in our Excel worksheet. As working with merged cells can be tricky you may want to avoid them altogether. If you want to read more of my blog posts on merged cells you can do so below.
Related Blog Posts On Merged Cells
To Merge Or Not To Merge That is The Question
How To Find All Merged Cells In Your Worksheet
What Does The Macro Do?
This piece of code is really simple and is designed to remove the merged property from a range of cells selected by the user.
How Does It Work?
This macro uses unmerge method which separates a merged area into individual cells. So let’s get coding. First, we need to open Visual Basic – by hitting ALT +F11 or Developer Tab – Visual Basic – Insert Menu – Module
Step 1. Declare Our Variables. We have one two Object Variables in this code. We are declaring the active worksheet and the range of cells.
Dim ActWorksheet As Worksheet
Dim MyRange As Range
Step 2. We now store the current worksheet and the selected range of cells.
Step 3. We now un-merge any merged cells in the selected cell range, the macro now ends.
That’s it now time to test the macro!
Want To Copy The Code?
[stextbox id=”grey”]
Private Sub UnMergeMyCells()
‘macro by HowToExcelAtExcel.Com’
Dim ActSheet As Worksheet
Dim MyRange As Range
Set ActSheet = ActiveSheet
Set MyRange = Selection
MyRange.UnMerge
End Sub
[/stextbox]
You can also watch my YouTube Video on how to find merged cells in Excel. Don’t forget to Subscribe and Turn on notifications.
If you want to see all of my blog posts in the Macro Mondays Series you can find them all in the link below. Why not bookmark it?, Yes it is updated EVERY Monday.
How To Excel At Excel – Macro Mondays Blog Posts.