Restore the lost zero in a phone number
Turn 2079460123 into 02079460123 when you know the width is 11.
What you'll make

The formula

| Number | Part | What it does | Result so far |
|---|---|---|---|
| 1 | AND( … ) | Checks for a whole number that fits the width. | TRUE |
| 2 | REPT("0",B8) | Makes a pattern of zeros, one per digit. | "00000000000" |
| 3 | TEXT(A8, … ) | Writes the number in that pattern, adding zeros in front. | "02079460123" |
| 4 | "Review phone width" | What the cell says for anything else. | Not used for row 8 |
| 5 | IF( … ) | Gives part 3 when part 1 is TRUE, otherwise part 4. | "02079460123" |
Parts 2 and 3 work from the inside out. The result is text, so the zero stays. The numbers here are made-up.
=IF(AND(ISNUMBER(A8),A8>=0,A8=INT(A8),LEN(TEXT(A8,"0"))<=B8),TEXT(A8,REPT("0",B8)),"Review phone width")How to use it
Yellow bar at the top? Click Enable Editing.
- See it work. The Example tab shows 20 made-up examples with the formula already in.
- Use your own numbers. Paste numbers and widths into the green columns of the Template tab. The phones fill in by themselves.
- Move them into your letter. Copy the results. Then use Paste Special and choose Values.
Before you send
Use this only when your source says every number had this width. It can't guess a width for you.
Microsoft's help: TEXT function
OTHER ROUTES YOU MIGHT LIKE

Remove phone separators, keep the plus
(201) 555-0123 → 2015550123
Get the template →
Remove a leading 1 from 11-digit phones
12015550123 → 2015550123
Get the template →
Get a phone number from a tel link
tel:+12015550123;ext=12 → +12015550123
Get the template →
Hide "Phone:" when there's no phone number
(blank) → no "Phone:" line
Take this route →