Enter a Date as Text with General Format in Excel VBA
Question details
Enter a date-like string with VBA while keeping it as text and leaving the cell formatted as General.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- A VBA macro needs to write a date-like value without Excel converting it to a date.
- Observed behavior
- The value should display exactly as entered, remain text, and have a General number format.
Identify the target cell and the exact date-like string you want to preserve. Make sure the Developer tab is available and save the workbook as an .xlsm file if you need to retain the macro.
Write the value as text before applying General format
Use this VBA sequence to preserve the characters in a date-like string while leaving the cell's final format as General.
Setting General format after assigning a value does not undo a conversion to an Excel date. Format the cell as Text before writing the string, then change the format to General.
In Excel, select Developer > Visual Basic, then choose Insert > Module.
Paste this code into the module, replacing A1 and the string as needed: Sub EnterDateAsText() With ActiveSheet.Range("A1") .NumberFormat = "@" .Value2 = "02/01/2022" .NumberFormat = "General" End With End Sub
Select the target worksheet, then run EnterDateAsText from Developer > Macros. Check that the cell displays 02/01/2022 and that =ISTEXT(A1) returns TRUE.

Work with date-like text in WPS Spreadsheets
WPS Office is a free, lightweight alternative for working with spreadsheets in a familiar interface. Open compatible Excel files and manage cell formats as you move your work to WPS. VBA support varies by WPS edition and platform.

Frequently Asked Questions
Why does my date-like value turn into a number after I apply General format?
Excel may have converted the string into a date when it was assigned. General format can then display the underlying date serial number. Set NumberFormat to "@" before assigning the string.
How can I check whether the cell contains text?
In an empty cell, enter =ISTEXT(A1), replacing A1 with the target cell. TRUE means the value is stored as text.
Can I use row and column variables instead of A1?
Yes. Replace ActiveSheet.Range("A1") with ActiveSheet.Cells(x, y), where x is the row number and y is the column number.
Will changing the cell to General convert the text into a date?
Changing the number format alone does not normally convert an existing text value. Check the result with =ISTEXT(A1) after running the macro.




