Test in a live environment
Test in production without watermarks.
Works wherever you need it to.
Many people find it challenging to understand how to merge cells in Excel. At first, this may seem like a daunting task, but we've got your back! This blog will walk you through how to quickly merge cells in Excel.
IronXL is a C# Excel library with many advanced features for Excel operations. One main benefit of the IronXL C# library is that you don't need to install Excel software locally on your system. It processes the Excel document without using Excel software.
You can create a new Excel file and format data according to your needs using the IronXL C# library. It is a complete go-to package for all Excel operations. If you are building any software and have to create or edit an Excel file in your software, you can quickly perform such tasks with the help of the IronXL library. To use this library in your software build, you must download its DLL file or install it with NuGet Package Manager. You can use the free trial version to test all the features. The trial version is free, and it is very straightforward to use the license key with your project. You can also use this tutorial to better understand it. Once you are satisfied with IronXL, you can buy it at a very reasonable price.
Next, we will talk about how to merge cells in Excel using the IronXL C# library. IronXL provides elementary and easy-to-use functions to read and merge cells in an Excel file. Let's examine how to join cells in C# language using the IronXL library:
Use IronXL in your project.
a. using IronXL;
Load an Excel book using WorkBook.Load()
static function.
a. WorkBook wb = WorkBook.Load("fileaddress.xlsx");
When the Excel file loads, select the sheet where we merge cells using the GetWorkSheet()
function.
a. WorkSheet ws = wb.GetWorkSheet("SheetName");
We have selected the sheet where we have to merge cells. Let's choose the cell address to merge using the Merge()
function.
a. ws.Merge("FromCell:ToCell");
Selected cells are merged, and now it's time to save the edited file using the SaveAs()
function.
a. wb.SaveAs("Filename.xlsx");
You can download a zip file project that demonstrates how to merge cells.
Microsoft Excel is a spreadsheet application that helps users organize, analyze, and share data. It is one of the most popular office software programs to date. The goal of Excel is to simplify analyzing and managing data so people to be more productive at work. This particular tutorial will discuss how to merge cells in Excel. Before proceeding to examine how to join cells in Excel, you need to have a basic working knowledge of the following terms: cells and ranges.
A cell is the smallest unit of data in a spreadsheet. This is where you enter data, formulas, and other information. Every spreadsheet has a grid made up of rows and columns, and every cell in the grid is assigned an address that uniquely identifies it on the grid. You can identify cells by their location in the grid, such as A1 or B3.
A cell range is a group of cells with different addresses. For example, a cell range with two numbers must be formatted as A1:A5. In Excel, the default reference style is "Cells," which must be changed if you want to use a different one. There are two kinds of ranges: horizontal and vertical. Each type has its purpose and uses.
Merging cells is essential because it saves time when working with large tables with many rows and columns. When merging cells, the software will automatically center on the merged cell so that there's no need to adjust it manually. When we merge cells, most upper-left cell values are retained. This will also make your table look nicer and easier to read. Let's look at how we can merge multiple cells in Excel.
Navigate to Merge Button in Excel
The Merge & Center button is the simplest method to merge cells in Excel. Let's examine how to merge cells using this method:
Excel File opened in Microsoft Excel
Select two cells
Now click on the Merge & Center button to merge selected cells.
Merge & Center button
Merged cell displayed in Microsoft Excel
This method automatically merges cells and makes content aligned as centered. It is important to note that the software always preserves the furthest upper-left cell value. Other values will be discarded.
You can merge cells using the "Format Cells" dialogue box. This gives you multiple options. Let's examine how to merge cells using the "Format Cells" dialogue box:
Open your file in the Excel Software.
Excel File opened in Microsoft Excel
Select the cells you want to merge.
Selecting cells
Open the "Format Cells" dialogue box. You can open it in various ways.
Go to the Home tab and click on the arrow icon on the Format button in the Cells section, and from the dropdown, select the Format Cells option.
Navigate to Format Cells button
You can open the Format Cells dialogue box using the keyboard shortcut Ctrl + 1.
The third way to open this dialogue box is to right-click on selected cells and select the Format Cells menu.
Accessing Format Cells from right-click menu
The Format Cells dialogue box will open. Go to the alignment tab, select merge cells, and click the OK button.
Format Cells dialog
Selected cells will be merged. You can identify merged cells by checking the borderlines of the cells.
Merged cell
Notice that data in cells is not centered using this technique. This needs to be done manually from the home tab using the formatting section.
You can perform this task quickly if you don't want to use your mouse, and instead use the keyboard to merge cells. You must select the cells you want to join and press Alt + H + M + C simultaneously. Your selected cells will be merged.
If you want to use the merge tool frequently, you can add this option to your quick-access toolbar. Let's look at how we can add the Merge and Center option to the Quick Access toolbar.
Go to the title bar and click on the little arrow icon. It will show a dropdown. From the dropdown, select the More Commands option.
Navigate to More Commands
A new pop-up box will open. Scroll down and select the Merge and Center option.
Excel Options UI
After selecting Merge and Center, click the Add button, and this will add the command to the Quick Access toolbar options. Next, press OK to apply this change.
Adding Merge & Center button into the toolbar
Now, you can use the Merge and Center option using the Quick Access toolbar.
Quick Access toolbar UI
You can use this button using Alt with another key. You can see which key is related to the Quick Access toolbar option by clicking the Alt key.
Quick Access toolbar UI with Shortcut key displayed
You can use the Alt + 5 key combination to merge cells quickly.
If you wish to combine data from two or more columns, then the Merge and Center option will not work because it retains only the first cell's data and discards that from other cells. If you try to merge two or more cells that contain data, it will give you a warning as shown below:
Discard data dialog
To combine the data from cells, you have to use an Excel function called the "Concatenate" function. Let's see how it works.
Let's say we want to combine a first name and a second name.
Data displayed before using concatenate Function
We can't do it using the Merge and Center option. We will do it using the Concatenate function. Now move to the cell after the second name, where the data will be combined.
Type =Concatenate() and in parameters, give the address of those cells whose data you want to merge, like this:
Adding a new cell with concatenate function
Press Enter, and you will see that the data from the two cells has been merged.
The result using Excel function
Next, select the cell where the data is combined and dragged from the user to apply a function on other cells in the column.
Applying to multiple cells in the same column
The final result
You will see that the data from the two cells have been combined. You can now delete the columns if you don't want them.
We can unmerge cells with a straightforward method:
This is how you can unmerge cells very quickly. If you wish to unmerge all merged cells in Excel, you can do it easily as follows:
9 .NET API products for your office documents