How to Prevent Excel from Hiding Digits in Text Product Numbers
Question details
The user wants to stop Excel from automatically converting product numbers formatted as text into numeric values when using features like Find and Replace or Text to Columns.

- Product
- Excel
- Device & OS
- not provided
- Scenario
- Manipulating product numbers that contain dashes or periods using Find and Replace or Text to Columns.
- Observed behavior
- Excel misinterprets the text strings as numeric values, causing digits to be hidden, changed, or incorrectly formatted.
Before running any macros or applying bulk formatting changes, ensure you have saved a backup copy of your dataset to prevent unintended data loss or irreversible formatting errors.
Use a VBA Macro to Replace Characters and Preserve Text Format
Using a VBA macro allows you to safely replace characters like dashes with periods without triggering Excel's automatic numeric conversion.
When you use the standard Find and Replace tool on text containing dashes, Excel may attempt to evaluate it as a formula or numeric value. A simple VBA script bypasses this behavior by directly replacing the string values while maintaining the text format.
Press Alt + F11 to open the Visual Basic for Applications (VBA) editor in Excel.
Click on 'Insert' in the top menu and select 'Module' to create a new module window.
Copy and paste the following code into the module window: Sub TestMacro() Dim rngC As Range For Each rngC In Selection If InStr(rngC.Value, "-") > 0 Then rngC.Value = Replace(rngC.Value, "-", ".") End If Next rngC End Sub
Close the VBA editor. Highlight the cells containing your product numbers in the spreadsheet, press Alt + F8, select 'TestMacro', and click 'Run'.

Pre-format Cells with a Specific Number Format
Altering the cell formatting to a specific decimal structure before using Find and Replace can sometimes prevent digits from disappearing.
Safely Edit Text and Numbers Using WPS Spreadsheet
WPS Spreadsheet provides excellent control over cell formatting, allowing you to seamlessly process product numbers and text strings without unintended numeric conversions. It fully supports VBA macros to automate data cleanup tasks.
- 1. Open the Spreadsheet: Launch WPS Spreadsheet and open your workbook containing the product numbers.
- 2. Format Column as Text: Select the target column, navigate to the Home tab, click the Number Format dropdown, and explicitly set it to 'Text' to lock the format.
- 3. Execute Replacement or Macros: Use Ctrl + H to safely replace characters, or navigate to the Developer tab to run custom macros ensuring your data stays exactly as typed.

Frequently Asked Questions
Why does Excel automatically change my text numbers into dates or values?
Excel has built-in automatic data recognition. When it detects patterns like dashes or periods in a string, it often attempts to convert them into dates or scientific notation to save time, which unfortunately can alter text-based product numbers.
Does the Text to Columns feature always convert text to numbers?
By default, Text to Columns will try to interpret the split data. To prevent this, in Step 3 of the Text to Columns Wizard, you must explicitly highlight each column in the Data preview window and set the Column data format to 'Text'.
How can I force a cell to remain text when manually typing a product number?
You can force Excel or WPS Spreadsheet to treat an entry as text by typing an apostrophe (') before the number, or by pre-formatting the blank cell range to 'Text' before pasting or typing your data.




