Merge cells

How to merge cells using Excel and VBA methods

METHOD 1. Merge cells using a ribbon option

EXCEL

Select cells you want to merge > Home tab > Alignment group > Merge & Center > Merge Cells

1. Select the cells that you want to merge.
Note: in this example we are merging cells A2 to D2.
Select cells

2. Select the Home tab. Select Home tab - Excel 2016

3. Click on the Merge & Center arrow, in the Alignment group.
4. Click on Merge Cells.
Click on Merge & Center and click on Merge Cells

METHOD 2. Merge cells using cell format

EXCEL

Select cells you want to merge > Right-click on selected range > Format Cells > Alignment tab > Check Merge cells checkbox > Click OK

1. Select the cells that you want to merge.
Note: in this example we are merging cells A2 to D2.
Select cells

2. Right-click anywhere on the selected area.
3. Select Format Cells.
Right-click on selected area and click Format Cells

4. Select the Alignment tab.
5. Check the Merge cells checkbox.
6. Click OK.
Select Alignment tab, check Merge cells and click OK

METHOD 1. Merge cells using VBA

VBA

Sub Merge_Cells()
'merge range A2:D2 in a worksheet named Sheet1
Worksheets("Sheet1").Range("A2:D2").Merge

End Sub

PREREQUISITES
Worksheet Names: Have a worksheet named Sheet1.
ADJUSTABLE PARAMETERS
Sheet Selection: Select the worksheet in which you want to merge cells by changing the Sheet1 worksheet name in the VBA code.
Merge Cell Selection: Select the range of cells you want to merge by changing range ("A2:D2") in the VBA code.

METHOD 2. Merge selected cells using VBA

VBA

Sub Merge_Cells()
'merge selected cells
Selection.Merge

End Sub

Explanation about how to merge cells

EXPLANATION

EXPLANATION
This tutorial explains and provides step by step instructions on how to merge cells.

Excel Methods: This tutorial provides two Excel methods that can be applied to merge cells. Both of the methods are very similar to each other, with one using the Home tab and the other using the Format cells option. The first method can be accomplished in four steps, whilst the second in six steps.

VBA Methods: This tutorial provides two VBA methods that can be applied to merge cells. The first method merges the cells specified in the VBA code. The second method merges the selected cells.

RELATED TOPICS

Related Topic Description Related Topic and Description
How to unmerge cells using Excel and VBA methods
How to fit content in a cell without adjusting column width using Excel and VBA methods
How to unwrap content in a cell using Excel and VBA methods