Sub topic 3
How Excel decides what you typed
This chapter assumes you can open a workbook, select a cell, and type into it. It also assumes you know what rows, columns, and cells are. Here you learn how Excel classifies an entry as text, a number, a date or time, or a formula. You also learn how to predict that classification and how to override it.
Why classification matters
When you press Enter, Excel does not store your keystrokes as they are. It reads the entry, picks a data type, and stores a value of that type. The type decides how the cell aligns, how it sorts, whether it can be used in arithmetic, and which formats apply.
Most data-entry surprises come from a mismatch. You meant a part code and Excel stored a number. You meant a fraction and Excel stored a date. Learning the decision rules lets you predict these cases before they happen.
The four kinds of entry
Excel recognizes four kinds of entry:
- Text is any entry that Excel cannot read as one of the other three kinds. Examples are
Invoice,A-100, and12 Main St. - Numbers are values Excel can calculate with. Examples are
42,-3.5,1,200,12%,$5.00, and1.5E3. - Dates and times are stored as numbers, but Excel recognizes the typed pattern and applies a date or time format.
- Formulas start with an equals sign and are calculated instead of stored literally.
The decision order
Excel works through a rough sequence each time you commit an entry.
The order is a teaching model. Excel's real parser also depends on your regional settings, but the model predicts most results.
Formulas
An entry that begins with = is treated as a formula. Excel also accepts + or - as a first character in many cases and converts the entry to a formula, so +A1+B1 works. If you want a literal text entry that begins with an equals sign, start it with an apostrophe.
Entering formulas has its own chapter, so only the classification rule matters here. A leading = means "calculate this."
Numbers
Excel accepts a wide range of number patterns. Each one stores a number and also applies a display format that matches what you typed.
| You type | Stored as | Format Excel applies |
|---|---|---|
| `1200` | 1200 | General |
| `1,200` | 1200 | Number with thousands separator |
| `$5` | 5 | Currency |
| `12%` | 0.12 | Percentage |
| `1.5E3` | 1500 | Scientific, or General if short |
| `(100)` | -100 | Number with parentheses |
Notice the percentage row. Typing 12% stores 0.12, not 12. The cell only displays 12%. The gap between stored and displayed values is the subject of a later chapter, but it begins here: the format is chosen from what you typed.
Numbers align to the right by default. Text aligns to the left. This is the quickest visual check of how Excel read an entry.
Dates and times
If an entry matches a date or time pattern for your regional settings, Excel stores it as a serial number and applies a date format. With US settings, 3/15, 3-15, Mar 15, and 15-Mar are all read as March 15 of the current year. A pattern such as 9:30 is read as a time.
Details of date entry, including two-digit years and regional differences, come in a later chapter. For now, remember that many entries that look harmless are dates. A common one is a fraction typed directly, as described below.
Text
If nothing else matches, Excel stores the entry as text. Text can hold up to 32,767 characters in a cell, though only about 1,000 characters show in the cell itself. The rest is visible in the formula bar.
Text entries are left-aligned. Text that looks like a number, such as a stored 00123, behaves differently from a real number. It sorts as text, it is ignored by SUM, and Excel may flag it with a small green triangle in the corner of the cell.
Overriding the decision
You can force an entry to be text, or you can enter a value in a way that avoids misreading.
Typing an apostrophe
A leading apostrophe tells Excel to store the rest of the entry as text.
'00123The cell stores 00123 as text and keeps the leading zeros. The apostrophe is not displayed in the cell. You see it only in the formula bar when the cell is selected. Excel stores the apostrophe as a formatting flag, not as part of the text.
Building text with a formula
If the source value is already in a cell, you can produce padded text with the TEXT function.
=TEXT(A1,"00000")This returns the number in A1 as text padded with leading zeros to five digits. If A1 holds 123, the result is 00123. The result is a formula, so it changes when A1 changes. Copy it and paste as values if you need fixed text.
Entering fractions
Typed directly, 1/2 is usually read as a date, such as January 2 or February 1 depending on your region. To enter the fraction as a number, 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 1/2. The zero and space tell Excel that this is a mixed number with a whole part of zero. The cell takes a fraction format automatically.
Long numbers
Excel keeps only 15 significant digits of precision. If you type a 16-digit number such as a card number, the sixteenth digit becomes 0. Entries of 12 or more digits in a General-format cell may also display in scientific notation. For identifiers that are not used in arithmetic, such as account numbers, phone numbers, and IDs, enter them as text with an apostrophe or format the cell as Text before typing.
Checking what Excel decided
You do not have to guess. Use these checks after you commit an entry:
- Look at the alignment. Right-aligned usually means number or date. Left-aligned usually means text.
- Select the cell and read the formula bar. A leading-zero value shown there with no apostrophe may still be text if the cell has a Text format.
- Look at the number format box on the Home tab. It shows General, Number, Date, Text, and so on.
- Check for the green triangle. It often marks a number stored as text.
- Use a helper formula such as
=ISNUMBER(A1)or=ISTEXT(A1).
=ISNUMBER(A1)This returns TRUE if A1 holds a real number or a date, and FALSE if it holds text.
Common errors
- Leading zeros vanish. Excel read the entry as a number. Use an apostrophe or Text format before typing.
- A fraction becomes a date. Type
0 1/2instead of1/2. - A code like
1-2becomes a date. Enter it as text with an apostrophe. - A long number ends in zeros. The entry exceeded 15 digits. Store it as text.
- Sums ignore some cells. Those cells are text that looks like numbers. Check alignment and the green triangle.
- An entry starting with
=shows an error. Excel tried to calculate it. Start with an apostrophe if you meant text.
Exercise
You type 1/2 into a cell and Excel displays a date. You also type 007 and it displays 7. For each entry, what should you type to keep your intended value, and what does Excel store in each case?
Show answer
Type 0 1/2 for the fraction. Excel stores the number 0.5 and displays 1/2. Type '007 for the zeros. Excel stores the text 007 and does not display the apostrophe in the cell.
Exercise
A column of IDs sums to 0 even though the cells appear to hold numbers. Name two quick checks that show whether the cells are text, and say what you would conclude.
Show answer
Check the alignment, since left-aligned entries suggest text, and use =ISNUMBER(A1), which returns FALSE for text. Either result shows that the cells hold text that looks like numbers, so SUM ignores them.