VBA & Macro Problems

Enter a Date as Text with General Format in Excel VBA

Natalie TaylorNatalie Taylor Nov 18, 2026 870 views

Question details

Enter a date-like string with VBA while keeping it as text and leaving the cell formatted as General.

Enter a Date as Text with General Format in Excel VBA
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.
Before you start

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.

Solution 1Recommended

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.

1
Open the VBA editor

In Excel, select Developer > Visual Basic, then choose Insert > Module.

2
Add the macro

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

3
Run and verify

Select the target worksheet, then run EnterDateAsText from Developer > Macros. Check that the cell displays 02/01/2022 and that =ISTEXT(A1) returns TRUE.

Write the value as text before applying General format
Text is not an Excel date: The stored value preserves its characters, including leading zeros, but it cannot be used directly in date calculations as a numeric Excel date.
Free Microsoft Office alternative

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.

Format spreadsheet cells as Text to preserve date-like entriesOpen and edit compatible Microsoft Excel formats, including XLSXUse a familiar spreadsheet interface for an easier transitionWork in a free, lightweight office suite
microsoft office alternative - wps office

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.