Note: The other languages of the website are Google-translated. Back to English
English English

Excel Formula: Add Leading zero to fix text length

If there is a list of numbers in a worksheet, for looking much neater, you may want to add leading zeros to force them in a fixed length as below screenshot shown. In this tutorial, it provides a formula which uses the TEXT function to easily handle this job.
doc abbreviate words 1

Generic formula:



Txt: the cell reference or text string you want to fix the length.
0_length: a string of zeros which used to set the length of string you need. Supposing you want to make text length in 6 characters, you can use “000000” in the formula as this TEXT(txt,”000000”)


This formula will change the cell formatting to text formatting.

This formula only work for number string, if the string is text formatting, it returns the original data.

How this formula work

To fix the numbers in list of cell B3:B8 to five character, please use below formula:


Press Enter key and drag fill handle to the cell B8.


TEXT function is used to convert numbers to text in a specified formatting.

Sample File

doc sampleClick to download sample file

Relative Formulas

Relative Functions

  • TEXT function
    Convert number to text with a specific format.
  • REPLACE function
    Find and replace characters based on given location from text string with a new text.
  • LEFT function
    Extract characters from left side of text.
  • MID function
    Extract part of text from a cell value based on the location and length.

The Best Office Productivity Tools

Kutools for Excel - Helps You To Stand Out From Crowd

Would you like to complete your daily work quickly and perfectly? Kutools for Excel brings 300 powerful advanced features (Combine workbooks, sum by color, split cell contents, convert date, and so on...) and save 80% time for you.

  • Designed for 1500 work scenarios, helps you solve 80% Excel problems.
  • Reduce thousands of keyboard and mouse clicks every day, relieve your tired eyes and hands.
  • Become an Excel expert in 3 minutes. No longer need to remember any painful formulas and VBA codes.
  • 30-day unlimited free trial. 60-day money back guarantee. Free upgrade and support for 2 years.
Ribbon of Excel (with Kutools for Excel installed)

Office Tab - Enable Tabbed Reading and Editing in Microsoft Office (include Excel)

  • One second to switch between dozens of open documents!
  • Reduce hundreds of mouse clicks for you every day, say goodbye to mouse hand.
  • Increases your productivity by 50% when viewing and editing multiple documents.
  • Brings Efficient Tabs to Office (include Excel), Just Like Chrome, Firefox, And New Internet Explorer.
Screen Shot of Excel (with Office Tab installed)
Comments (0)
No ratings yet. Be the first to rate!
There are no comments posted here yet
Leave your comments
Posting as Guest
Rate this post:
0   Characters
Suggested Locations