Microsoft Excel aligns text to the bottom left and numerals to the bottom right of cells by default. You may easily change the default alignment by utilizing the ribbon, keyboard shortcuts, the Format Cells dialog, or by creating your own unique number format. This article will show you how to middle align in Excel.
In this article, we will apply two methods that are very convenient to middle align in Excel. We will utilize the Alignment group and apply the VBA code to the middle alignment in Excel. Let’s suppose we have a sample data set.
1. Utilizing Alignment Group to Middle Align
Alignment is the third group in the Home tab ribbon, following the Clipboard and the Font groups. There are more than ten buttons, including the drop-down menu buttons. Most importantly, Alignment group buttons can be used to position, rotate, and align the content within a cell. The alignment of the texts is set, in particular, via the Top Align, Middle Align, and Bottom Align buttons. Additionally, in addition to the buttons for Align Left, Center Align, and Align Right. Orientation, Increase Indent, and Decrease Indent are also options. Here, we will use the middle align icon which will center the contents between the top and bottom of the cell.
- Here, select the data set, and then you will see that the data set does not show the middle alignment.
- Therefore, we want to do the middle alignment.
- Here, select the data set that you want to do the middle alignment.
- Firstly, go to the Home tab.
- Then, click on the Middle Align from the Alignment group.
- Finally, you will observe that all texts and numbers in the cell are centered between the top and the bottom of the cell.
2. Applying VBA Code to Middle Align in Excel
VBA is a programming language that may be used for various tasks, and different types of users can use it for those tasks. You can launch the VBA editor using the Alt + F11 keyboard shortcut. In the last section, we will generate a VBA code that makes it easy to middle align in Excel.
- Firstly, we will open the Developer tab.
- Then, we will select the Visual Basic command.
- Here, you will see all contents in the cell do not show the middle alignment.
- Here, the Visual Basic window will open.
- After that, from the Insert option, we will choose the new Module to write a VBA code.
- Then, paste the following VBA code into the Module.
- To run the program, click the “Run” button or press F5.
Sub Middle_Alignment() 'Specifying the range for middle alignment Range("B4:C11").VerticalAlignment = xlCenter End Sub
- Lastly, the given image displays all the texts and numbers in the selected range showing the middle alignment.
Download Practice Workbook
You may download the following Excel workbook for better understanding and practice it by yourself.
In this article, I’ve covered 2 handy methods to middle align in Excel. I sincerely hope you enjoyed and learned a lot from this article. If you have any questions, comments, or recommendations, kindly leave them in the comment section below.
- All Types of Alignment in Excel
- How to Change Alignment in Excel
- [Fixed!] Excel Cell Alignment Not Working