Function Problems

Remove Spaces from UPC Codes in Excel Without Losing Leading Zeros

Anum MushtaqAnum Mushtaq Dec 2, 2026 869 views

Question details

Remove spaces from UPC codes while preserving or restoring leading zeros and keeping formulas available after saving.

Remove Spaces from UPC Codes in Excel Without Losing Leading Zeros
Product
Microsoft Excel
Device & OS
not provided
Scenario
A user is cleaning UPC codes such as 0000 007 1600 and wants an 11-digit result.
Observed behavior
Leading zeros may be lost when a code is converted to a number, and formulas may not remain usable after the data is saved as plain text.
Before you start

Check whether the UPC cells are stored as text or numbers, and confirm the required code length. If importing a text or CSV file, set the UPC column to Text during import so Excel does not remove its leading zeros.

Solution 1Recommended

Remove spaces from UPC codes stored as text

Use SUBSTITUTE when the original codes still contain their leading zeros.

1
Enter the formula

In an empty cell such as B2, enter =SUBSTITUTE(A2," ","") and press Enter. Replace A2 with the cell containing your UPC code.

2
Fill the column

Select B2 and drag its fill handle down to apply the formula to the remaining codes. For example, 0000 007 1600 becomes 00000071600.

3
Save the formulas

Select File > Save As and choose Excel Workbook (*.xlsx) to keep the formulas in the workbook.

Remove spaces from UPC codes stored as text
Check the space character: This formula removes ordinary spaces. Other whitespace characters, such as nonbreaking spaces, require a different substitution.
Work with UPC codes in WPS

Clean UPC Codes with WPS Spreadsheets

Use formulas in WPS Spreadsheets to remove spaces from text codes or pad numeric codes to a known length, then save the workbook with its formulas.

  1. 1. Open the spreadsheet: Open WPS Spreadsheets and select Open to load the workbook containing your UPC codes.
  2. 2. Remove spaces: In an empty cell, enter =SUBSTITUTE(A2," ","") for a code stored as text, then press Enter.
  3. 3. Pad numeric codes if needed: For a code already stored as a number, enter =TEXT(A2,REPT("0",11)) instead, changing 11 to the required digit count.
  4. 4. Fill and save: Drag the formula cell's fill handle down, then select File > Save As and choose an XLSX workbook.
Remove spaces while preserving leading zeros in text UPC codesPad numeric codes to a specified length with TEXTOpen and save Microsoft Excel XLSX filesUse a familiar spreadsheet interface
microsoft office alternative - wps office

Frequently Asked Questions

How do I keep leading zeros when importing UPC codes into Excel?

Select Data > From Text/CSV, choose the file, and set the UPC column's data type to Text during import. This prevents Excel from treating the codes as numbers.

Why did my formulas disappear after saving?

A plain-text file such as CSV does not reliably preserve spreadsheet formulas and workbook features. Use File > Save As and select Excel Workbook (*.xlsx) to retain them.

Can I replace the original UPC column with the cleaned codes?

Yes. Copy the formula results, select the destination cells, and use Home > Paste > Paste Special > Values. The pasted results will no longer depend on the formulas.

Can Excel recover the original leading zeros from a number?

Excel cannot infer how many zeros were originally present. If you know the required length, use =TEXT(A2,REPT("0",11)), replacing 11 with that length.