Formatting Issues

How to Prevent Excel from Hiding Digits in Text Product Numbers

Adam DavisAdam Davis Oct 29, 2026 868 views

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.

How to Prevent Excel from Hiding Digits in Text Product Numbers
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 you start

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.

Solution 1Recommended

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.

1
Open the VBA Editor

Press Alt + F11 to open the Visual Basic for Applications (VBA) editor in Excel.

2
Insert a New Module

Click on 'Insert' in the top menu and select 'Module' to create a new module window.

3
Paste the Macro Code

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

4
Run the Macro on Selected Cells

Close the VBA editor. Highlight the cells containing your product numbers in the spreadsheet, press Alt + F8, select 'TestMacro', and click 'Run'.

Use a VBA Macro to Replace Characters and Preserve Text Format
Verification: Always check the formula bar after running the macro to ensure the leading zeros and exact digit counts are preserved as text.
Manage Data Efficiently

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. 1. Open the Spreadsheet: Launch WPS Spreadsheet and open your workbook containing the product numbers.
  2. 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. 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.
Complete compatibility with Microsoft Excel formats (.xlsx, .xls, .csv)Advanced Find and Replace tools with precise format preservationFull support for VBA macros to automate complex text manipulations
microsoft office alternative - wps office

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.