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 explains the rules Excel uses to classify an entry as a formula, a number, a date or time, or text. Knowing the rules lets you predict the result and fix surprises.
The classification order
When you press Enter, Excel inspects the typed characters and assigns a data type. It checks roughly in this order:
- If the entry starts with
=, it is a formula. - If it can be read as a number, it is a number. This includes values such as
1,250,12%,$5, and1.2E3. - If it matches a date or time pattern for your regional settings, it is a date or time. Excel stores these as numbers.
- Otherwise, it is text.
How to see the type Excel chose
Excel gives you visible clues. By default:
- Numbers, dates, and times align to the right of the cell.
- Text aligns to the left.
- A formula shows its result in the cell and its source in the formula bar.
Alignment is only a hint, because you can change it manually. A more reliable check is to select the cell and look at the Number Format box on the Home tab. General means Excel applied no specific format. You can also test the entry with a formula.
=ISNUMBER(A1)This returns TRUE for a number or a date, and FALSE for text.
Common surprises
The same keystrokes can give different types depending on what you type:
| You type | Excel stores | Why |
|---|---|---|
| `42` | Number | Digits only |
| `42 apples` | Text | Letters make it unreadable as a number |
| `3/4` | Date (4 March of the current year) | Matches a date pattern |
| `12-5` | Date | Matches a date pattern |
| `00123` | Number 123 | Leading zeros are dropped |
| `=A2*B2` | Formula | Starts with `=` |
Two of these cause most of the trouble. A fraction typed as 3/4 becomes a date, and an ID such as 00123 loses its zeros. Both come from step 2 and step 3 of the order above. Excel reads your entry as a number or date before it considers text.
Overriding the decision
You can force text by typing an apostrophe before the entry. Excel keeps 00123 as text and does not display the apostrophe in the cell.
'00123You can also produce padded text with a formula.
=TEXT(A1,"00000")For a fraction, type a zero, a space, and then the fraction. Excel stores 0.5 and displays 1/2.
Type 0 1/2 in a cell and press EnterA third option is to set the cell's Number Format to Text before you type. Excel then treats later entries in that cell as text. This does not convert values that are already in the cell.
Common errors
- Assuming right alignment proves a number. A manual alignment change can hide the real type.
- Typing a date in a format your regional settings do not recognize. The entry then stays as text.
- Formatting a cell as
Textafter typing a number and expecting it to convert. It does not.
Exercise
You type 1/2 into a cell and Excel shows 2-Jan. Why did this happen, and what should you type to get the number 0.5 shown as 1/2?
Show answer
Excel checked the entry against its date patterns and read 1/2 as a date (1 February in some settings, displayed here as 2-Jan after the cell's format changed). To enter the fraction, type 0, a space, and then 1/2. Excel stores 0.5 and displays 1/2.