Clean phone numbers and postal codes using Excel formulas

Transform irregular contact details into uniform formats for clean CRM imports. Use this whenever raw exports mix dashes, dots, spaces, or leading zeroes.

Text prompt for ChatGPT and Claude

You get: Formula breakdown, how it works and what to check

Prompt

Prompt
Act as an Excel formula specialist. Write clean, reliable Excel formulas to standardize messy phone numbers and postal codes based on the sample data provided below.

- Provide formulas that work in standard Excel (such as TEXT, SUBSTITUTE, TRIM, or modern REGEX/LAMBDA where appropriate).
- Handle common edge cases like missing leading zeroes, variable lengths, and unwanted punctuation (dots, spaces, dashes, parentheses).
- Clearly specify which column or cell reference your formula assumes.
- Provide a fallback formula for users on older Excel versions (without modern array functions).

Output format:
- Formula breakdown: Show each target format and its exact formula.
- How it works: A 2-sentence explanation of the logic.
- What to check: 2-3 validation checks before running a bulk import.

My raw data samples are below:

Example output

Example for: US 10-digit phone numbers and 5-digit zip codes with lost leading zeroes

Formula breakdown

1. Standardize 10-Digit Phone Numbers to (XXX) XXX-XXXX
Assuming raw phone number is in cell A2:
=LET(digits, REDUCE("", {"(",")","-"," ","."}, LAMBDA(str,char, SUBSTITUTE(str, char, ""))), TEXT(VALUE(digits), "(000) 000-0000"))

Legacy Excel Formula (A2):
=TEXT(VALUE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A2," ",""),"-",""),"(",""),")","")), "(000) 000-0000")

2. Standardize 5-Digit US Postal Codes (Restoring Leading Zeroes)
Assuming raw postal code is in cell B2:
=TEXT(TRIM(B2), "00000")

How it works

The phone formula strips away common punctuation, converts the remaining text into a numeric value, and uses the TEXT function to apply consistent formatting. The postal code formula trims extraneous whitespace and forces a five-character numeric mask so East Coast postal codes like 07001 retain their leading zeroes.

What to check
  • Look for international numbers with country codes (more than 10 digits), as they will display incorrectly under a 10-digit mask.
  • Confirm that no alphanumeric postal codes (like Canadian or UK formats) are routed into numeric TEXT masks.
  • Convert formulas to values via Copy > Paste Special > Values before importing to your CRM.
Written by AI from this prompt. Your results will vary.

Paste your raw sample phone numbers and postal codes at the bottom in ChatGPT, Claude, or Gemini. As a follow-up, ask how to wrap the formulas with IFERROR to catch blank cells cleanly.

Reuse it: Use in a workflowTurn into a skillAdapt in the builder

Excel & Spreadsheets

Strip hidden characters and non-printing breaks in Excel

Remove hard carriage returns, non-breaking spaces, and invisible ASCII artifacts that break lookups. Use this after copying data from web forms or PDFs.

Excel & Spreadsheets

Deduplicate spreadsheet rows keeping latest entry

Finds duplicate records in your data and generates clean formulas or step-by-step instructions to keep only the newest record.

Excel & SpreadsheetsGemini

Write Google Sheets REGEX Formulas to Extract and Clean Text

Get ready-to-paste REGEXEXTRACT, REGEXREPLACE, or REGEXMATCH formulas for Google Sheets with a token-by-token breakdown.

Excel & Spreadsheets

Parse Unstructured Text into Clean Excel Columns

This prompt generates specific Excel formulas to split messy text strings into organized columns while handling edge cases like missing delimiters.

Excel & Spreadsheets

Create a sorted unique dropdown list from raw data

Extract sorted, deduplicated values from raw operational data to build a clean dynamic Excel dropdown menu.

Excel & Spreadsheets

Fix divide-by-zero errors in Excel variance formulas

Eliminate #DIV/0! errors in budget variance calculations with clean, professional handling for zero or missing values.