Cleaning Up Your Excel 2010 Data
Illustration by John Hersey

Managing leading zeroes in zip, numerical, and text codes


From:

Cleaning Up Your Excel 2010 Data

with Dennis Taylor

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.

Start your free trial now, and begin learning software, business and creative skills—anytime, anywhere—with video instruction from recognized industry experts.

Start Your Free Trial Now
please wait ...
Watch the Online Video Course Cleaning Up Your Excel 2010 Data
1h 26m Appropriate for all Nov 01, 2011

Viewers: in countries Watching now:

In this course, Dennis Taylor explores the functions, commands, and techniques in Excel that restructure data, remove unwanted characters, convert date data into the desired format, and prepare data for efficient analysis. This course helps get data from a business management system file, other database software, a text file, or a poorly designed Excel worksheet into optimal shape for working with in Excel.

Topics include:
  • Moving or inserting rows and columns of data with a simple drag
  • Using Text to Columns
  • Harnessing the Find and Replace command to replace data at the character level
  • Dealing with special characters and wildcards during search
  • Converting dates with text functions
  • Converting text data to values/numbers
  • Checking and correcting spelling mistakes
  • Splitting data into multiple columns via the Text to Columns feature
  • Combining data from different columns via concatenation
Subjects:
Business IT
Software:
Excel
Author:
Dennis Taylor

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.

Find answers to the most frequently asked questions about Cleaning Up Your Excel 2010 Data .


Expand all | Collapse all
please wait ...
Q: Where can I learn more about Excel formulas?
A: Discover more on this topic by visiting Excel formulas on lynda.com.
 
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

* Estimated file size

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 ?

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 preferences from 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.

Learn more, save more. Upgrade today!

Get our Annual Premium Membership at our best savings yet.

Upgrade to our Annual Premium Membership today and get even more value from your lynda.com subscription:

“In a way, I feel like you are rooting for me. Like you are really invested in my experience, and want me to get as much out of these courses as possible this is the best place to start on your journey to learning new material.”— Nadine H.

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.