Merge Multiple Cells into One Cell using Macros (VBA) in Excel 365!!
Tags: mergemultiplecellsin, vbamacros
Published: 2021-02-23 11:58:50

---
title: Merge Multiple Cells into One Cell using Macros (VBA) in Excel 365!!
published: true
date: 2021-02-23 09:26:13 UTC
tags: Mergemultiplecellsin,VBAMacros
canonical_url: https://geekexcel.com/merge-multiple-cells-into-one-cell-using-macros-vba-in-excel-365/
---

If you want to merge multiple cells into one without losing data, what will you do? Here, we come up with some simple steps to **merge multiple cells into one cell using Macros** & [VBA](https://geekexcel.com/excel-office-365-vba-overview-definition-and-examples/) in Excel Office 365. Let’s get into this article and learn the clear-cut steps to finish this task quickly.
## Merge Multiple Cells into One Cell using Macros:

To combine multiple cells into a single cell in the Excel worksheet, do as follows.

- First, you need to open the workbook where you want to merge cells.
- Here, we have shown the example data range from **A1:B2**. We are going to combine these steps with the help of macros.

![Example range](https://eadn-wc04-371788.nxedge.io/cdn/wp-content/uploads/2021/02/EXCEL_alPA0CEQmL.png)<figcaption id="caption-attachment-22070">Example range</figcaption>

- On the **Developer Tab, select** the **Visual Basic** option under the **Code** section.

![Select Visual Basic option](https://eadn-wc04-371788.nxedge.io/cdn/wp-content/uploads/2020/09/Select-Visual-Basic-option-4.png)<figcaption id="caption-attachment-14755">Select the Visual Basic option</figcaption>

- Then you need to copy and paste the code given below.

VBA code to combine multiple cells into one using Macros

Sub MergeCells()

Dim xJoinRange As Range

Dim xDestination As Range

Set xJoinRange = Application.InputBox(prompt:=”Highlight source cells to merge”, Type:=8)

Set xDestination = Application.InputBox(prompt:=”Highlight destination cell”, Type:=8)

temp = “”

For Each Rng In xJoinRange

temp = temp & Rng.Value & ” “

Next

xDestination.Value = temp

End Sub

- You need to **save the code** by selecting it. Then **close** the **window.**

![Save the code](https://eadn-wc04-371788.nxedge.io/cdn/wp-content/uploads/2021/02/EXCEL_IXppYvOxyd.png)<figcaption id="caption-attachment-22071">Save the code</figcaption>

- You have to open the sheet containing the data. On the **Developer Tab, choose** the **Macros option** in the **Code** section.

![Choose the Macros option](https://eadn-wc04-371788.nxedge.io/cdn/wp-content/uploads/2020/09/Choose-the-Macros-option-2.png)<figcaption id="caption-attachment-14747">Choose the Macros option</figcaption>

- You need to make sure that your macro is selected and **click** the **Run** button.

![Click the Run button](https://eadn-wc04-371788.nxedge.io/cdn/wp-content/uploads/2021/02/EXCEL_2i2Q3iS1so.png)<figcaption id="caption-attachment-22072">Click the Run button</figcaption>

- You need to **select** the **input range** and **click** the **OK** button.

![Input dialog box](https://eadn-wc04-371788.nxedge.io/cdn/wp-content/uploads/2021/02/EXCEL_MEcVoKumaE.png)<figcaption id="caption-attachment-22073">Input dialog box</figcaption>

- Now, you have to **select the destination cell** to place the result.

![Click OK button](https://eadn-wc04-371788.nxedge.io/cdn/wp-content/uploads/2021/02/EXCEL_mlgQGb6eUJ.png)<figcaption id="caption-attachment-22074">Click OK button</figcaption>

- Finally, you will get the result as shown in the below image.

![Output](https://eadn-wc04-371788.nxedge.io/cdn/wp-content/uploads/2021/02/EXCEL_nRvfgovovt.png)<figcaption id="caption-attachment-22075">Output</figcaption>

## Wrap-Up:

In this article, we have illustrated the clear-cut steps to **merge multiple cells into one cell using Macros** & [VBA](https://geekexcel.com/excel-office-365-vba-overview-definition-and-examples/) in Excel Office 365. Leave your **feedback** in the below comment section. Thanks for visiting **[Geek Excel.](https://geekexcel.com/)** Keep Learning!

### Keep Reading:

- [Highlight Cells with a Single Space using Macros (VBA) in Excel!!](https://geekexcel.com/highlight-cells-with-a-single-space-using-macros-vba-in-excel/)
- [Highlight Max Value in Selection using Macros (VBA) in Excel 365!!](https://geekexcel.com/highlight-max-value-in-selection-using-macros-vba-in-excel-365/)
- [Resize All Charts using Macros (VBA) in Excel Office 365!!](https://geekexcel.com/resize-all-charts-using-macros-vba-in-excel-office-365/)