VBA Code to Convert MM.DD.YYYY To DD.MMM.YYYY in Excel
VBA Code to Convert MM.DD.YYYY To DD.MMM.YYYY in Excel : CODE
'This function converts a date from MM.DD.YYYY to system date format Public Function ConvertToDate(strInputDate As String) As Date 'Variable Declaration Dim iMonth As Integer Dim iDay As Integer Dim lYear As Long ' 'Get month from first 2 digits If IsNumeric(Left(strInputDate, InStr(1, strInputDate, ".") - 1)) = True Then iMonth = Left(strInputDate, InStr(1, strInputDate, ".") - 1) Else ConvertToDate = Null Exit Function End If 'Get day from input date If IsNumeric(Mid(strInputDate, InStr(1, strInputDate, ".") + 1, 2)) = True Then iDay = Mid(strInputDate, InStr(1, strInputDate, ".") + 1, 2) Else ConvertToDate = Null Exit Function End If 'Get year from last 4 digits If IsNumeric(Right(strInputDate, 4)) = True Then lYear = Right(strInputDate, 4) Else ConvertToDate = Null Exit Function End If 'Create a complete date and return the value ConvertToDate = CDate(iDay & "-" & MonthName(iMonth) & "-" & lYear) ' End Function
To Convert the Date Format use this code in your Excel file, follow the below steps
1. Open an Excel file
2. Press Alt+F11
3. Insert a Module (Insert>Module) from menu bar
4. Paste the code in the module
5. Now write ConvertToDate formula in a cell and select the cell which contains a date in MM.DD.YYYY format
8. In the ‘Number’ tab, click on ‘Date’ category and select the format type you want to display (here I have selected DD-MMM-YYYY format)
9. Done, your date is converted. You can drag the formula to other cells as well
Download Practice File for Free
To help you practice this code, we have made this code available through practice file. Click on the below link to download the practice file.
Excel VBA Course : Beginners to Advanced
We are offering Excel VBA Course for Beginners to Experts at discounted prices. The courses includes On Demand Videos, Practice Assignments, Q&A Support from our Experts. Also after successfully completion of the certification, will share the success with Certificate of Completion
This course is going to help you to excel your skills in Excel VBA with our real time case studies.
Lets get connected and start learning now. Click here to Enroll.
Secrets of Excel Data Visualization: Beginners to Advanced Course
Here is another best rated Excel Charts and Graph Course from ExcelSirJi. This courses also includes On Demand Videos, Practice Assignments, Q&A Support from our Experts.
This Course will enable you to become Excel Data Visualization Expert as it consists many charts preparation method which you will not find over the internet.
So Enroll now to become expert in Excel Data Visualization. Click here to Enroll.
Use Automated Excel Utility Tools to increase productivity
Hope you are enjoying learning Excel with us, if you want any support related to this article, please do comment else you can ask questions in Excel Community