3 easy methods to convert month name to number in Excel
In Excel, there are times when you need to convert month names to their corresponding numbers to facilitate data analysis and processing. This tutorial will cover three methods to convert month names to numbers: using a formula, using Kutools for Excel, and using VBA code. Whether you are a beginner or an experienced Excel user, these methods will help you enhance your productivity.
Convert month name to number in Excel
This section covers three methods to convert month names to numbers: using a formula, using Kutools for Excel, and using VBA code. Each method is tailored to cater to different user preferences and technical capabilities, ensuring flexibility and ease of use across various Excel scenarios.
Use formula to convert month name to number in Excel
Using a formula is a simple and flexible way to convert month names to numbers. Excel's built-in formula functions are powerful, allowing us to create a formula that automatically converts month names. Let's walk through the steps to achieve this.
Type the following formula into a blank cell, and press the Enter key. Select this formula cell and drag its Fill Handle down to get the rest of the results.
=MONTH(A2&1)
Easily convert date to corresponding month number with Kutools
If you want to convert an entire date to its corresponding month name and prefer a simpler approach, Kutools for Excel is a highly useful tool. It's Apply Date Formatting features can simplify your workflow. Here are the steps to convert dates to corresponding month numbers using Kutools for Excel.
After free downloading and installing Kutools for Excel, please do as below:
- Select the dates you want to convert to month number, then select Kutools > Format > Apply Date Formatting.
- In the popped out Apply Date Formatting dialog box, choose the 03 option in the Date format list, and then click OK. You can preview the results in real time in the Preview pane.
Result
All dates in the selected range have been converted to corresponding month names immediately.
Use VBA code to convert month name to number in Excel
1. Hold ALT button and press F11 on the keyboard to open a Microsoft Visual Basic for Application window.
2. Click Insert > Module, and copy the VBA into the module.
VBA code: Convert month name to number
Sub ChangeNum()
'Updateby20140311
Dim Rng As Range
Dim WorkRng As Range
On Error Resume Next
xTitleId = "KutoolsforExcel"
Set WorkRng = Application.Selection
Set WorkRng = Application.InputBox("Range", xTitleId, WorkRng.Address, Type:=8)
For Each Rng In WorkRng
If Rng.Value <> "" Then
Rng.Value = Month(DateValue("03/" & Rng.Value & "/2014"))
End If
Next
End Sub
3. Click Run to run the VBA code, and a KutoolsforExcel dialog pops up for you to select a range of cells with month names that you want to convert to numbers, then click OK, the selecetd month names have been converted to month numbers. See screenshot:
Tip: Using the above VBA may lose your original data, you can save them before you running the VBA code.
Convert date to month number or month name or other date formats
Best Office Productivity Tools
Supercharge Your Excel Skills with Kutools for Excel, and Experience Efficiency Like Never Before. Kutools for Excel Offers Over 300 Advanced Features to Boost Productivity and Save Time. Click Here to Get The Feature You Need The Most...
Office Tab Brings Tabbed interface to Office, and Make Your Work Much Easier
- Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project.
- Open and create multiple documents in new tabs of the same window, rather than in new windows.
- Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day!
![Screen Shot of Excel (with Office Tab installed)](http://cdn.extendoffice.com/images/stories/kte-module/officetab-bottom-02.gif)
![rhoneyman](http://cdn.extendoffice.com/media/com_easydiscuss/images/default_avatar.png)
![gvg](http://cdn.extendoffice.com/media/com_easydiscuss/images/default_avatar.png)
![M BAMAGA](http://cdn.extendoffice.com/media/com_easydiscuss/images/default_avatar.png)
![Nihar Panda](http://cdn.extendoffice.com/media/com_easydiscuss/images/default_avatar.png)
![maharba](http://cdn.extendoffice.com/media/com_easydiscuss/images/default_avatar.png)