How to Identify a Value Type with TYPE in Excel
TYPE returns a code for what a cell holds — number, text, logical or error — so you can debug messy inputs.
You will learn to
- Read TYPE codes 1, 2, 4, 16 and 64
- Translate a TYPE code into words
- Validate an input while handling blanks correctly
How it works
TYPE(value) returns a number describing what kind of value it was given: 1 for a number (dates included), 2 for text, 4 for a logical TRUE/FALSE, 16 for an error and 64 for an array. Unlike ISERROR, TYPE does not itself error on a bad value, so it is useful for debugging cells whose contents you are unsure about.
Watch out for blanks: TYPE of an empty cell is 1, the same as a number. Check ISBLANK first when empty values matter. Pair TYPE with SWITCH to turn the code into words: =SWITCH(TYPE(B3),1,"Number",2,"Text",4,"True/False",16,"Error","Other").
=SWITCH(TYPE(B3),1,"Number",2,"Text",4,"True/False",16,"Error","Other")