How to Convert Text to Dates with Excel VBA
Question details
The user needs to convert text-formatted dates (such as 'MAR 23 2025' or '23/03/2025') in a specific column into valid Excel serial dates using VBA.

- Product
- Excel
- Device & OS
- not provided
- Scenario
- Cleaning up imported or manually entered data where dates are stored as text strings, making them unusable for chronological sorting or date arithmetic.
- Observed behavior
- Dates are stored as text and are not recognized by Excel as valid date values, requiring a programmatic way to parse and convert them while preserving already valid dates.
Ensure you have saved a backup copy of your workbook, and verify that the text dates you want to convert are consistently located in a specific column (like Column D) before running the macro.
Use a VBA Macro to Parse and Convert Text Dates
Use a custom VBA script to loop through your target column, identify text cells, and convert them safely using the Split, DateValue, and DateSerial functions.
This approach loops through the specified range (e.g., Column D) and checks if the cell contains text. Depending on the delimiter format—whether separated by spaces ('MAR 23 2025') or slashes ('23/03/2025')—it parses the string and reconstructs a proper Excel date to avoid regional settings conflicts.
In your open Excel workbook, press 'Alt + F11' on your keyboard to launch the Microsoft Visual Basic for Applications editor.
Click on 'Insert' in the top menu bar and select 'Module' to create a blank script window.
Copy and paste the following code into the module window: Sub ConvertDates() Dim rng As Range Dim parts() As String Application.ScreenUpdating = False For Each rng In Range(Range("D2"), Range("D" & Rows.Count).End(xlUp)) If Application.IsText(rng.Value) Then parts = Split(rng.Value) If UBound(parts) > 0 Then rng.Value = DateValue(parts(1) & "-" & parts(0) & "-" & parts(2)) Else parts = Split(rng.Value, "/") If UBound(parts) > 0 Then rng.Value = DateSerial(parts(2), parts(1), parts(0)) End If End If End If Next rng Application.ScreenUpdating = True End Sub
Close the VBA Editor, return to your worksheet, press 'Alt + F8', select 'ConvertDates' from the Macro dialog box, and click 'Run'.
Convert Text Dates Using Text to Columns (Non-VBA)
If you prefer not to use VBA, Excel's built-in Text to Columns tool is a fast and effective way to fix text dates in a single column without writing any code.
Process and Analyze Data Efficiently with WPS Office
WPS Spreadsheet provides powerful data processing tools, including built-in Text to Columns and robust VBA/Macro support, allowing you to easily convert and manage complex date formats.
- 1. Open your file in WPS Spreadsheet: Launch WPS Office and open the workbook containing your text dates.
- 2. Access the Developer Tools: Go to the 'Tools' tab and click on 'Developer' to access the VBA editor where you can run your date conversion macro.
- 3. Use Text to Columns: Alternatively, select your dates, navigate to the 'Data' tab, and use 'Text to Columns' to quickly parse dates without any coding required.

Frequently Asked Questions
Why doesn't Excel recognize my dates automatically?
Excel relies on your system's regional settings to interpret dates. If the imported text date format (like dd/mm/yyyy) differs from your system's default setting (like mm/dd/yyyy), Excel fails to parse it and treats it as a simple text string.
Can I convert text dates without using VBA?
Yes, you can use the 'Text to Columns' feature under the Data tab. Alternatively, you can use formulas like DATEVALUE() combined with text manipulation functions (LEFT, MID, RIGHT) to parse the text into a valid date structure.
What does the CDate function do in VBA?
The CDate function converts a valid string expression into a Date data type. However, it relies heavily on your computer's locale settings, which is why explicit parsing using DateSerial is often a safer choice for irregular or non-standard date formats.




