Creating a macro to merge cells in Excel

posted in: Excel Tutorials | 0

Creating a macro to merge cells in Excel – VBA Merge Cells

VBA Merge cells

For a guide to how to edit macros for your own purposes, please click here.

In this video we outline how to create a Macro in Microsoft Excel which merges any created cells you wish. This is a handy Excel merge shortcut and is a quick solution using VBA merge commands. This video is a next step to a former video where we outlined how to add a new row only, which can be located here. In this tutorial we use the VBA Merge Cells (VBA mergecells) code which can be found below.

This is very useful for keeping information in a timely order, where certain cells are also merged.

The video can be located below.

If you have any questions please post these onto the YouTube channel.


Excel VBA Merge Cells Video Tutorial – (VBA Mergecells)



The VBA Mergecells code that we use in this video is as follows. Please remember that this is a follow on tutorial building on previous macro examples and therefore all of the code below may not be entirely of use to you. We have outlined the code which only merges cells below for clarity.


VBA Merge Cells

Private Sub CommandButton1_Click()

ActiveCell.EntireRow.Insert shift:=xlDown

Selection.Borders.Weight = xlThin

ActiveCell.Formula = “=sum(a4:d4)”


End Sub

As always you will need to tailor this code to fit your own needs. The specific code we are interested in to merge cells in this is example is the following line.


By using this you can quickly auto merge cells in Excel.

To download this workbook please click the following link…

INR + FORM + Merge


For more Excel Tutorials please visit my channel at this link.

If this has been helpful then please like or subscribe to the channel.

Leave a Reply