Sub topic 4
Keeping leading zeros, long numbers, and fractions as you intend
This chapter assumes you can type into a cell, commit with Enter, and read the formula bar. It covers three cases where Excel's automatic reading of your entry changes what you meant: leading zeros, long digit strings, and fractions.
Why Excel changes your entry
When you type digits, Excel treats them as a number. A number has no leading zeros and holds at most 15 significant digits. Excel drops the zeros and zeroes out the digits past the fifteenth. It also reads some patterns, such as 1/2, as dates. To keep what you typed, you have to tell Excel to store the entry as text, or to read it as the number you mean.
Keeping leading zeros
Zip codes, product codes, and employee IDs often start with zero. Typing 00123 gives you 123.
Type an apostrophe before the digits:
'00123Excel stores 00123 as text. The apostrophe is not displayed in the cell, but you can see it in the formula bar.
You can also build the text with a formula. If A1 holds the number 123, this returns "00123":
=TEXT(A1,"00000")The result is text, padded with zeros to five digits. Use this when the numbers already exist and you don't want to retype them.
Long numbers
Credit card numbers and other long identifiers have 16 or more digits. Excel keeps only 15 significant digits, so it replaces the rest with zeros. A 16-digit number typed as 1234567890123456 is stored as 1234567890123450. A very wide number may also display in scientific notation, such as 1.23457E+15.
The fix is the same as for leading zeros. Type an apostrophe first, or format the cell as Text before you type. Text keeps every digit.
The trade-off is that text cannot be used in arithmetic. You would not add up credit card numbers, so text is the right choice for identifiers.
Fractions
Typing 1/2 is usually read as a date, such as 2-Jan or 1-Feb, depending on your regional settings. To enter the fraction, type a zero, a space, and then the fraction:
Type 0 1/2 in a cell and press EnterExcel stores the number 0.5 and displays it as 1/2. Because it is a real number, you can use it in formulas. For a mixed number, type the whole part, a space, and the fraction, for example 2 3/4.
Summary of the techniques
| You want | Type this | Stored as |
|---|---|---|
| 00123 | '00123 | Text |
| 1234567890123456 | '1234567890123456 | Text |
| One half | 0 1/2 | Number 0.5 |
| Zero-padded result from a number in A1 | =TEXT(A1,"00000") | Text |
Exercise
You type 0042 into a cell and Excel shows 42. Give two ways to get 0042 to display, and say what type of value each produces.
Show answer
Type '0042 so Excel stores it as text. Or, if 42 is already in A1, use =TEXT(A1,"0000") in another cell. Both produce text. (Formatting the cell as Text before typing also works.)
Exercise
You enter 1/4 to record a quarter and the cell shows a date. What should you type instead, and what number does Excel store?
Show answer
Type 0 1/4 (a zero, a space, then 1/4). Excel stores the number 0.25 and displays it as 1/4.