Pad Numbers With Zeros Using The LEFT Excel Function – Formula Friday


Hello, Excellers welcome to another Excel #formulafriday. Today I want to share with you a solution to a problem that is really quite common and I get asked about from time to time. How do you pad out your numbers in Excel with zeros?. For example, you may have an Excel worksheet that is imported into another database system. A field in the data requires numbers to be a specific length. For example customer numbers or references that need to be 10 characters in length. A solution to this if your customer numbers are currently too small or short, is to pad the numbers out with zeros. We will use the LEFT function or formula to extract the correct number of characters from a newly created text string.

Here is a sample of some data to demonstrate this issue.

All of my customer ID’s are currently 8 characters long, and my upload file expects 10. I just need to add two zeros to the end of the number to ensure they import into my database with no problems. I can do this by creating a new text string that joins my original Customer Id and 10 zeros, then force Excel to take the first 10 characters using the LEN function. Let’s walk through the formula.

How Does The Formula Work?

It is a clever formula. First, we join the value in Column A to a text string of 10 zeros to create a brand new text string.

We then use the LEFT function to extract the first 10 characters from this newly generated string.

Using The LEFT Function

The LEFT Function extracts a given number of characters from the left side of a string.

Syntax
=LEFT (text, [num_chars])
Where
  • text – The text from which to extract characters.
  • num_chars – [optional] The number of characters to extract, starting on the left side of the text. The default value is 1 if no value is specified.

Putting It All together.

By adding the LEFT function, we specify that after we created the new text string, we extract the first 10 characters from the left-hand side of the cell. This gives us the perfect field length required for import into our database. Easy!. How do you get over this issue with number padding?.

What Next? Want More Excel Tips?

If you want more Excel and VBA tips then sign up for my Monthly Newsletter where I share 3 Tips on the first Wednesday of the month and receive my free Ebook, 30 Excel Tips.

 

1

If you want to see all of the blog posts in the Formula Friday series. Click on the link below

How To Excel At Excel – Formula Friday Blog Posts.

More Excel Tips_New1
Learn Excel With Our Excel Online Courses

Do You Need Help With An Excel Problem?.

I am pleased to announce I have teamed up with Excel Rescue, where you can get help with Excel FAST.

ExcelRescue.net

 

Barbara

Barbara is an experienced data analyst with over 20 years of experience. Author of the How To Excel At Excel Top 50 Excel tips Ebook, YouTuber and Excel Blogger.

Recent Posts