Skip to main content

How to keep or delete leading zeros in Excel?

In general, when we type a number which contains leading zeros like 00032423 into a cell, it may show as 32423. And how can you keep these leading zeros in Excel? And in reverse, how can you delete the leading zeros when you do not need to show them?

Keep leading zeros with Format Cells

Delete leading zeros with VBA

Delete leading zeros with Kutools for Excel by clicks good idea3

Add/Delete same leading zeros with Kutools for Excel


arrow blue right bubble Keep leading zeros with Format Cells

If you want to keep the leading zeros in Excel, you just need to format the cells as Text formating befor you typing the data.

1. Select the range cells you want to type the data with leading zeros into, and right clcik to select Format Cells from the context menu. See screenshot:

doc-keep-delete-leading-zeor-1

2. In the Format Cells dialog, click Number tab, and select Text from the Category pane. Click OK to close the dialog. See screenshot:

doc-keep-delete-leading-zeor-2

Now when you type numbers with leading zeros into the range cells, the leading zeros will be retained in the cells. See screenshot:

doc-keep-delete-leading-zeor-3

Note: This method cannot work if you format cells as text after typing numbers.


One click to remove all leading zeros from cells in Excel

Just one click, all leading zeros of the cells in seletion have been removed.  Click for 30 days free trial!
doc remov leading zero
 
Kutools for Excel: with more than 300 handy Excel add-ins, free to try with no limitation in 30 days.

arrow blue right bubble Delete leading zeros with VBA

If you want to delete the leading zeros in Excel, you have four methods to solve it.

Method 1 Format cells as number formatting

Select the range you want to type number without showing leading zeros, and right click to click Format Cells to open Format Cells dialog, and select Number from the Category pane, then click OK. 

Note: This method cannot work if you format cells after typing number.

Method 2 Use a formula

Select a blank cell next to the range cells you have typed the numbers with leading zeros, and type this formula =VALUE(A1) (A1 indicates the cell contains numbers with leading zeros) into it. And press Enter button, now the number without leading zero is shown in the formula cell. See screenshot:

doc-keep-delete-leading-zeor-4

Method 3 Run a VBA

1. Press Alt + F11 to display the Microsoft Visual Basic for Applications window.

2. In the window, click Insert > Module to show a new module window, then copy the following VBA code into the module window.

VBA: Delete leading zeros in Excel

Sub DeleteZero()
'updateby20140616
Dim Rng As Range
Dim WorkRng As Range
On Error Resume Next
xTitleId = "KutoolsforExcel"
Set WorkRng = Application.Selection
Set WorkRng = Application.InputBox("Range", xTitleId, WorkRng.Address, Type:=8)
WorkRng.NumberFormat = "General"
WorkRng.Value = WorkRng.Value
End Sub
3. Click Run button, and a KutoolsforExcel dialog pops out for you to select a range to delete leading zeros. See screenshot:

doc-keep-delete-leading-zeor-5

4. Click OK. Then the leading zeros in selection are removed.

Method 4 Use Convert to Number feature

Select the range cells which are filled by numbers with leading zeros, click the warning icon besides the selection, and then select the Convert to Number from the context menu. See screen shot:

doc-keep-delete-leading-zeor-6


arrow blue right bubble Delete leading zeros with Kutools for Excel by clicks

Kutools for Excel, with more than 200 handy functions, makes your jobs more easier. 

After installing Kutools for Excel, please do as below:(Free Download Kutools for Excel Now!)

If you have Kutools for Excel, you can quickly delete all leading zeros from texts with two clicks by its Remove Leading Zeros utility

Select the text you want to delete the leading zeros, and then click Kutools > Text > Remove Leading Zeros. See screenshot:
doc delete leading zeros 01

Then a dialog pops out to remind that the leading zeros have been removed from how many cells. See screenshot:
doc delete leading zeros 02

Click OK to close the dialog.

arrow blue right bubble Delete Leading Zeros




arrow blue right bubble Add/Delete leading zeros with Kutools for Excel

If you want to add or delete the same number of leading zeros to a cell, you can apply Kutools for Excel's Add Text and Remove by Position utilities, one can help you add same number of leading zeros to cells, one help you remove same number of string from left of the cells.

After installing Kutools for Excel, please do as below:(Free Download Kutools for Excel Now!)

Add same number of leading zeros

1. Firstly, you need to format the cells as Text by selecting them and clicking Home and go to Numeric group to select Text from the drop down list. See screenshot:
doc kutools 1

2. And then keep these cells selected, and click Kutools > Text > Add Text. See screenshot:
doc kutools 2

3. In the Add Text dialog, type the zeros you want to add into the textbox of Text, and check Before first character option, and you can preview the adding result in the right pane. See screenshot:
doc kutools 3

4. Click Ok or Apply, now the same number of leading zeros are added into cells.
doc kutools 4

Delete same number of leading zeros

1. Select cells you want to delete the leading zeros, and click Kutools > Text > Remove by Position. See screenshot:
doc kutools 5

2. In the popping dialog, type the number of zeros you want to remove, check option, and you can preview the result in the Preview pane.
doc kutools 6

3. Click Ok or Apply, now the leading zeros are removed at once.


Tabbed browsing & editing multiple Excel workbooks/Word documents as Firefox, Chrome, Internet Explore 10!

You may be familiar to view multiple webpages in Firefox/Chrome/IE, and switch between them by clicking corresponding tabs easily. Here, Office Tab supports similar processing, which allow you to browse multiple Excel workbooks or Word documents in one Excel window or Word window, and easily switch between them by clicking their tabs. Click for free 30-day trial of Office Tab!

ot excel

Relative Articles:

Best Office Productivity Tools

🤖 Kutools AI Aide: Revolutionize data analysis based on: Intelligent Execution   |  Generate Code  |  Create Custom Formulas  |  Analyze Data and Generate Charts  |  Invoke Kutools Functions
Popular Features: Find, Highlight or Identify Duplicates   |  Delete Blank Rows   |  Combine Columns or Cells without Losing Data   |   Round without Formula ...
Super Lookup: Multiple Criteria VLookup    Multiple Value VLookup  |   VLookup Across Multiple Sheets   |   Fuzzy Lookup ....
Advanced Drop-down List: Quickly Create Drop Down List   |  Dependent Drop Down List   |  Multi-select Drop Down List ....
Column Manager: Add a Specific Number of Columns  |  Move Columns  |  Toggle Visibility Status of Hidden Columns  |  Compare Ranges & Columns ...
Featured Features: Grid Focus   |  Design View   |   Big Formula Bar    Workbook & Sheet Manager   |  Resource Library (Auto Text)   |  Date Picker   |  Combine Worksheets   |  Encrypt/Decrypt Cells    Send Emails by List   |  Super Filter   |   Special Filter (filter bold/italic/strikethrough...) ...
Top 15 Toolsets12 Text Tools (Add Text, Remove Characters, ...)   |   50+ Chart Types (Gantt Chart, ...)   |   40+ Practical Formulas (Calculate age based on birthday, ...)   |   19 Insertion Tools (Insert QR Code, Insert Picture from Path, ...)   |   12 Conversion Tools (Numbers to Words, Currency Conversion, ...)   |   7 Merge & Split Tools (Advanced Combine Rows, Split Cells, ...)   |   ... and more

Supercharge Your Excel Skills with Kutools for Excel, and Experience Efficiency Like Never Before. Kutools for Excel Offers Over 300 Advanced Features to Boost Productivity and Save Time.  Click Here to Get The Feature You Need The Most...

Description


Office Tab Brings Tabbed interface to Office, and Make Your Work Much Easier

  • Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project.
  • Open and create multiple documents in new tabs of the same window, rather than in new windows.
  • Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day!
Comments (21)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
I want to keep the leading zero's when I copy from the program I use at work & paste onto excel with out having to manually re-enter them. I would also like to keep them when I use my scanner into excel. Using the 'Text' format I can manually re-enter them into the cell & they will stay. Is there a format so that they go in with the leading zero's already there?
This comment was minimized by the moderator on the site
Hi, McJoe, I do not understand your question clearly, if you want to copy text string with leading zeros from a program, maybe Word document, and paste them to a worksheet and keep the leading zeros, you just format the cells as text before you pasting.
This comment was minimized by the moderator on the site
I want to remove the zero infront of the - 3TT-0233449.How do I go about it?
This comment was minimized by the moderator on the site
This comment was minimized by the moderator on the site
Thanks it worked
This comment was minimized by the moderator on the site
This is the BEST Excel site for years going! IDK how they do so much volume. WorkRng.Value = WorkRng.Value =VALUE(A1) brilliant code.
This comment was minimized by the moderator on the site
value(a1) worked great, thank you soo much !
This comment was minimized by the moderator on the site
BRILLIANT WORK!!! Excellent
This comment was minimized by the moderator on the site
I wanted to display "0001" instead of "1" in excel as Excel removes leading zeroes. Solution: Use Format Cells/ Custom format/ Type = "0000" Done. Instead this page refers to "Kutools" THIRTEEN times. Who's writing this page? Obviously the author of Kutools or someone getting a kickback from it!
This comment was minimized by the moderator on the site
If you needed to use your newly formatted number to conduct an HVLookup it will not match other data that may have embedded leading zero's. The formatting method you are referring to displays the number the way you want to see it but it will not be useful in a data match or lookup while the VBA will work.
This comment was minimized by the moderator on the site
This comment is very helpful and is the correct approach for must users looking to perform this function retroactively on their data.


The Shill is also very real, lol.
This comment was minimized by the moderator on the site
You can also do

format cell > text format ( instead of Number or accounting or Currency or general )
This comment was minimized by the moderator on the site
But how to keep the leading zeroes when I download data directly from my website or from my warehouse program? The download is directly in excel, so I can not modify anything in advance. Is there any option in excel which determines in advance that the entire column or sheet must be read (downloaded) as text?
This comment was minimized by the moderator on the site
download file in.txt and open excel and desired column select and go to format cell and select as text, after this please open your .txt file and copy from .txt file and paste it in xl.... Done
This comment was minimized by the moderator on the site
Is there any way to do it from Excel tools ? In case we have n number of records this method is of no use.
This comment was minimized by the moderator on the site
using value(a1) worked great for deleting leading zeros
This comment was minimized by the moderator on the site
Nice try slick, your methods don't work. Didn't try VBA, surely there's an easier way than that.
There are no comments posted here yet
Load More
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations