Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member

Managing leading zeroes in zip, numerical, and text codes

From: Cleaning Up Your Excel 2010 Data

Video: Managing leading zeroes in zip, numerical, and text codes

If you use numeric codes that begin with zeros--and of course some ZIP codes do begin with zero-- you need to be able to see and retain those zeros. There are a couple techniques we want to take a look at there. First of all, in Column A, let's imagine that someone typed the ZIP codes, maybe looking at a sheet of paper, heads down, just typing the zeros where appropriate, but the zeros actually didn't appear. So you can imagine, in Cell A5, for example, whoever was typing this probably typed 02299, as I'm typing here. So what happens though when we press Enter? The zero doesn't appear there.

Managing leading zeroes in zip, numerical, and text codes

If you use numeric codes that begin with zeros--and of course some ZIP codes do begin with zero-- you need to be able to see and retain those zeros. There are a couple techniques we want to take a look at there. First of all, in Column A, let's imagine that someone typed the ZIP codes, maybe looking at a sheet of paper, heads down, just typing the zeros where appropriate, but the zeros actually didn't appear. So you can imagine, in Cell A5, for example, whoever was typing this probably typed 02299, as I'm typing here. So what happens though when we press Enter? The zero doesn't appear there.

Now we wouldn't have to go through any shenanigans or anything unusual here; simply format Column A--right- click > Format Cells. And ideally, you do this before you put the data in--it makes a bit more sense--and you'll see correct entries as we go. There is a special category on the Number tab in Format Cells. It's called Special. And we got two ZIP code entries: Zip Code, the standard five digit, or the Zip Code + 4. In this case, just Zip Code. There we go, click OK. And the zeros are in place.

So in situations like that, for example suppose this ZIP code here needs to be changed and it's 00123, we'll just type 123, and the zeros pop into place automatically. So that's an easy fix. Now at other times we have situations like we see in columns C and D. Let's imagine that these ID numbers here, too, need to have leading zeros. Now everything in Column C is actually a number as it turns out, and here, too, we possibly could have been typing in leading zeros and then look up and see what's going on. But we need to make some adjustments here. And as we look at some of the numbers, recognize some are three digit, four digit, five digit.

We actually want to turn these into six-character ID numbers. So what we're seeing in Column D is actually what we want to have happen. So let's actually shows how this is set up. What we need to do here is to type in, in this particular example here, a function called =text. And we want to take the data from C2, comma. The text function requires that we give this a format, and the format is going to be within double quotes, six zeros.

Now the zeros, think of them sort of as placeholders that will contain values, and if there's no real value to be picked up, we'll see a leading zero, or zeros, as necessary. So six zeros, double quote and we don't need the right parenthesis here since it is just a single set, and we see what's happening. Copy this down the column. Now the others were already done anyway, but at least we see how that looks, and here's the function again. And you see what's happening. For example, in C5, the 814 now has three leading zeros.

So you can imagine some variations on how to use that as well. In Column F, a different situation. The code numbers here are a mix of letters and numbers, and we want them to turn into nine characters and have leading zeros. Here it's a little bit different, and what we want to do here is to use a function called rept, which means repeat. And what we would like to do is put in some leading zeros, so the symbol we want to put in, within double quotes, is a zero.

Now the question is, how many times do we want to put it in there? And look at the different entries in Column F. The first entry in Cell F2 is six characters long, the next one is seven, the next one after that looks like it's nine, and so on; it varies. So the total length here is 9. How many zeros do we need to put in here in cell F2? We need to put in 3. So, how do we figure that out? We want the number 9 minus the existing length. 9- and here is a function called len, meaning length.

So the length of F2 right now in this example is 6. So what we're about to say here--we're not finished with the formula just yet-- we want to take this zero character and put it in here in the first case three times. 9 minus the length of F2, which is 6. So we're going to put three leading zeros there, and then what are we going to put in? The ampersand means "and," the actual content of F2. There we are.

And we see what's happening and double- click, copy this down the column. And it had been set up again anyway, but just take any of these at random, take a look at them--for example, this one here. As we're looking at this, once again, in all cases here, the length is going to, well, here and there, vary. The length here is 5. 9-5 is 4. So how many leading zeros do we want here? Four leading zeros. So in these situations here in Column G, we're dealing with data that's a mix of numbers and texts.

Over in column D, we're dealing with all values. So there is a difference in how these are set up. But these are all using various text functions that allow us to take data that's not in the best of shape and turn it into the format that we would like. It's not always directly done by using the Format command, as you've seen in these examples here. Those are some great tools for cleaning up data and turning it into the appearance and the content that you want. Here, too, as in a lot of other examples, if we want to keep the results here, we would select all of this data, and it could be thousands and thousands of entries, possibly it might be better even to pick the column in that example.

We could adjust the headings later and simply with the right mouse button, drag this on top of Column F, let go, Copy Here as Values Only. Change your headings. We're all set. Get rid of this.

Show transcript

This video is part of

Image for Cleaning Up Your Excel 2010 Data
Cleaning Up Your Excel 2010 Data

24 video lessons · 16513 viewers

Dennis Taylor
Author

 

Start learning today

Get unlimited access to all courses for just $25/month.

Become a member
Sometimes @lynda teaches me how to use a program and sometimes Lynda.com changes my life forever. @JosefShutter
@lynda lynda.com is an absolute life saver when it comes to learning todays software. Definitely recommend it! #higherlearning @Michael_Caraway
@lynda The best thing online! Your database of courses is great! To the mark and very helpful. Thanks! @ru22more
Got to create something yesterday I never thought I could do. #thanks @lynda @Ngventurella
I really do love @lynda as a learning platform. Never stop learning and developing, it’s probably our greatest gift as a species! @soundslikedavid
@lynda just subscribed to lynda.com all I can say its brilliant join now trust me @ButchSamurai
@lynda is an awesome resource. The membership is priceless if you take advantage of it. @diabetic_techie
One of the best decision I made this year. Buy a 1yr subscription to @lynda @cybercaptive
guys lynda.com (@lynda) is the best. So far I’ve learned Java, principles of OO programming, and now learning about MS project @lucasmitchell
Signed back up to @lynda dot com. I’ve missed it!! Proper geeking out right now! #timetolearn #geek @JayGodbold
Share a link to this course

What are exercise files?

Exercise files are the same files the author uses in the course. Save time by downloading the author's files instead of setting up your own files, and learn by following along with the instructor.

Can I take this course without the exercise files?

Yes! If you decide you would like the exercise files later, you can upgrade to a premium account any time.

Become a member Download sample files See plans and pricing

Please wait... please wait ...
Upgrade to get access to exercise files.

Exercise files video

How to use exercise files.

Learn by watching, listening, and doing, Exercise files are the same files the author uses in the course, so you can download them and follow along Premium memberships include access to all exercise files in the library.


Exercise files

Exercise files video

How to use exercise files.

For additional information on downloading and using exercise files, watch our instructional video or read the instructions in the FAQ.

This course includes free exercise files, so you can practice while you watch the course. To access all the exercise files in our library, become a Premium Member.

Join now "Already a member? Log in

Are you sure you want to mark all the videos in this course as unwatched?

This will not affect your course history, your reports, or your certificates of completion for this course.


Mark all as unwatched Cancel

Congratulations

You have completed Cleaning Up Your Excel 2010 Data.

Return to your organization's learning portal to continue training, or close this page.


OK
Become a member to add this course to a playlist

Join today and get unlimited access to the entire library of video courses—and create as many playlists as you like.

Get started

Already a member?

Become a member to like this course.

Join today and get unlimited access to the entire library of video courses.

Get started

Already a member?

Exercise files

Learn by watching, listening, and doing! Exercise files are the same files the author uses in the course, so you can download them and follow along. Exercise files are available with all Premium memberships. Learn more

Get started

Already a Premium member?

Exercise files video

How to use exercise files.

Ask a question

Thanks for contacting us.
You’ll hear from our Customer Service team within 24 hours.

Please enter the text shown below:

The classic layout automatically defaults to the latest Flash Player.

To choose a different player, hold the cursor over your name at the top right of any lynda.com page and choose Site preferencesfrom the dropdown menu.

Continue to classic layout Stay on new layout
Exercise files

Access exercise files from a button right under the course name.

Mark videos as unwatched

Remove icons showing you already watched videos if you want to start over.

Control your viewing experience

Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.

Interactive transcripts

Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.

Are you sure you want to delete this note?

No

Your file was successfully uploaded.

Thanks for signing up.

We’ll send you a confirmation email shortly.


Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from lynda.com.

Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

   
submit Lightbox submit clicked
Terms and conditions of use

We've updated our terms and conditions (now called terms of service).Go
Review and accept our updated terms of service.