ExcelCSE.com

Menu
  • Excel 101
  • Excel Functions
  • Excel Formula
  • Contact Us
How to Use Excel > Excel Formula > Add and Remove Leading Zeros in Excel

Add and Remove Leading Zeros in Excel

How to Add & Remove Leading Zeros in Excel
Table of contents :

Add Leading Zeros in Excel

  • Add Leading Zeros for Numeric Values
    • Solution #1, using the Format Cells menu
    • Solution #2, using TEXT function
  • Add Leading Zeros for Non-numeric Values
    • Solution #3, using REPT and LEN function
  • Which One is the Best Solution?

Remove Leading Zeros in Excel

  • Remove Leading Zeros from Numeric Values
    • Solution #4, using the Format Cells menu
    • Solution #5, using a mathematical formula
  • Remove Leading Zeros from Alphanumeric Values
    • Solution #6, using Convert menu
    • Solution #7, using VALUE function
    • Solution #8, using TEXT function
  • Remove Leading Zeros from Non-numeric Values
    • Solution #9, using Excel Formula
  • Which One is the Best Solution?

Add remove leading zeros in excel

Add Leading Zeros in Excel

Add Leading Zeros for Numeric Values

How to add leading zeros to numbers in column A?

Add leading zeros in excel

Solution #1, using the Format Cells menu

How to add leading zeros in excel

Make a range selection A1:A7. Press CTRL+1 (Format Cells shortcut). Select Custom on the Number tab. Type a 7-digit zero number in the Fill type section, then click the OK button.

Excel show leading zeros

All numbers with less than seven digits have a leading zero. Pay attention to the red arrow at formula bar; there is no leading zeros, only number 1. Its means leading zero is only the appearance, the data is still a number.

Solution #2, using TEXT function

The Formula

=TEXT(A1,"0000000")

The Result

How to add a leading zero in excel

The result is the same as solution #1, but all data in column B are text, not numbers.

The formula bar displays the excel formula, not the data, to display the data, do a Copy – Paste Special – Values for all data in column B.

How to show leading zeros in excel

There are leading zeros in front of the number

Add Leading Zeros for Non-numeric Values

Solution #3, using REPT and LEN function

How to add leading zeros to text?

The Formula

=REPT("0",7-LEN(A1))&A1

The Result

Excel leading zeros formula

The excel REPT function write a text in N times. To get the N value, use the LEN function and subtract 7 by the LEN function result. The result is leading zero for non-numeric values.

Which One is the Best Solution?

To add a leading zero and keep the original values as a number, Format cells is the only option.

To add leading zero and convert it to text, you have two option. The excel TEXT function produces a simpler formula but adding leading zero for numeric values only. The otherwise, The REPT and LEN function able to add leading zero for numeric or non-numeric values.

The choice is yours.

Remove Leading Zeros in Excel

Remove Leading Zeros from Numeric Values

Solution #4, using Format Cells menu

Solution #4 is the opposite step in solution #1. Change cell format from custom to general.

Make a range selection A1:A7. Press CTRL+1 (Format Cells shortcut). Select General on the Number tab, then press ENTER.

Add remove leading zeros in excel

No leading zeros for all numbers.

Solution #5, using a mathematical formula

You can use all mathematical formulas to remove leading zeros, in one condition do not change the original value.

Addition formula

=A2+0

Subtraction formula

=A2-0

Multiplication formula

=A2*1

Division formula

=A2/1

All formulas above return the same results and all text changes to numbers.

Remove leading zeros in excel

Remove Leading Zeros from Alphanumeric Values

Solution #6, using Convert menu

How to remove leading zeros in excel

All data changes to numbers.

Solution #7, using VALUE function

The Formula

=VALUE(A1)

The Result

Remove leading zeros

All leading zero disappears, and all data become numbers.

Solution #8, using TEXT function

The Formula

=TEXT(A1,"#")

The Result

Excel remove leading zeros from text

All leading zero disappears, but the data remains as text.

Remove Leading Zeros from Non-numeric Values

Solution #9, using Excel Formula

The Formula

=RIGHT(A1,LEN(A1)-FIND(LEFT(SUBSTITUTE(A1,"0",""),1),A1)+1)

The Result

How to remove leading zeros

How does the formula above work?

The formula above looking for the first character position after leading zero, then take the character afterward.

The trick to finding the first character after the leading zero is to eliminate all “0” (zero) characters using the SUBSTITUTE function.

The Formula (Step1)

=SUBSTITUTE(A1,"0","")

How do you remove leading zeros in excel

All “0” (zero) characters disappear. Next is the LEFT function task to find the first character after leading zero.

The Formula (Step2)

=LEFT(SUBSTITUTE(A1,"0",""),1)

How to remove a leading zero in excel

After getting the first character after leading zero, the next step is to find the position of the character in the original data using the FIND function.

The Formula (Step3)

=FIND(LEFT(SUBSTITUTE(A1,"0",""),1),A1)

Delete leading zeros

After obtaining the first character position, the next step is to take all the characters from the first character position to the last.

Which function to use? Can you use the RIGHT function or MID function? Using the RIGHT function or MID function both need the LEN function.

The Formula (Step4)

=RIGHT(A1,LEN(A1)-FIND(LEFT(SUBSTITUTE(A1,"0",""),1),A1)+1)

Eliminate leading zeros in excel

The Formula (Step4, another alternative)

=MID(A1,FIND(LEFT(SUBSTITUTE(A1,"0",""),1),A1),LEN(A1))

Add remove leading zeros in excel

Which One is the Best Solution?

To remove leading zero from a number, do the opposite step of adding leading zero. Use the Format Cells menu (solution #4).

There are two options to remove leading zero from alphanumeric data, convert it to numbers or keep it as a text. To convert to a number the easiest way is to use the Convert menu (solution #6). If you want to keep it as a text, use the TEXT function (solution #8).

The hardest way is to eliminate leading zero for non-numeric value. You must use an excel formula and involve many functions, but that is the only option you have (solution #9).

Related Function

Function used in this article
  • Excel VALUE Function
  • Excel REPT Function
  • Excel LEN Function
  • Excel TEXT Function
  • Excel LEFT Function
  • Excel MID Function
  • Excel RIGHT Function
  • Excel SUBSTITUTE Function
  • Excel FIND Function

Related Articles

Another articles related to this article
  • Paste Special Excel
Usefull links
  • Microsoft Excel keeping leading zeros and large numbers documentation
Share
Tweet
Google+
Email
Prev Article
Next Article

Related Articles

How to calculate time difference in excel
How many hours between two times? To get hours between …

How to Calculate Time Difference in Excel

VLOOKUP MATCH
VLOOKUP MATCH – Solution for VLOOKUP REF Error The article …

VLOOKUP MATCH – a Combination for a Solution

Get the Original Price from Percentage Increase What was the …

Get the Original Price from Percentage Increase/Decrease

Excel Cell Reference
As already discussed in the article “How to Create a …

All about Excel Cell Reference

How to Separate Date and Time in Excel
The date and time value can be written in one …

How to Separate Date and Time in Excel

Tags:Add Leading Zeros Add Leading Zeros in Excel Delete Leading Zeros Eliminate Leading Zeros in Excel Excel Leading Zeros Formula Excel Pad Leading Zeros Excel Remove Leading Zeros From Text Excel Show Leading Zeros FIND Function How Do You Remove Leading Zeros in Excel How to Add a Leading Zero in Excel How to Add Leading Zeros in Excel How to Get Rid of Leading Zeros in Excel How to Remove A Leading Zero in Excel How to Remove Leading Zeros How to Remove Leading Zeros in Excel How to Show Leading Zeros in Excel LEFT Function LEN Function MID Function Paste Special Remove Leading Zeros Remove Leading Zeros in Excel REPT Function RIGHT Function SUBSTITUTE Function Text Function VALUE Function

Categories

  • Excel 101
  • Excel Formula
  • Excel Functions

Recent Posts

  • Get the Original Price from Percentage Increase/Decrease
  • How to Add/Subtract Percentage in Excel
  • How to Extract Day, Month and Year from Date in Excel
  • How to Add Seconds, Minutes and Hours to a Time in Excel
  • How to Add Days, Weeks, Months and Years to a Date in Excel
  • How to Calculate Time Difference in Excel
  • Calculate Number of Days, Weeks, Months and Years Between Two Dates in Excel
  • Flash Fill Excel
  • Paste Special Excel
  • Excel TEXTJOIN Function
  • Excel CONCAT Function
  • Excel CONCATENATE Function
  • Excel REPLACE Function
  • Excel SUBSTITUTE Function
  • Excel REPT Function
  • Excel FIND Function
  • Excel SEARCH Function
  • Excel MID Function
  • Excel RIGHT Function
  • Excel LEFT Function

ExcelCSE.com

The Ultimate Guide How to Use Excel Better
Copyright © 2024 ExcelCSE.com
Contact Us - Privacy Policy - Sitemap | Theme by MyThemeShop.com

Ad Blocker Detected

Our website is made possible by displaying online advertisements to our visitors. Please consider supporting us by disabling your ad blocker.

Refresh