Do Different Things for Text vs Numbers

Excel Formulas › Information

All versionsISNUMBER

Handle a mixed column gracefully — format numbers one way, label text another. ISNUMBER and ISTEXT let one formula branch on the cell’s data type.


Quick formula: label by type:
=IF(ISNUMBER(A2), "Number: "&A2, IF(ISTEXT(A2), "Text", "Other"))
Test the type, then return different output for numbers, text, or anything else.

Functions used (tap for the full reference guide):

The example

A mixed column routed by type.

AB
1CellHandled as
242Number
3abcText

The formula

Branch on the type:

=IF(ISNUMBER(A2), "Number", IF(ISTEXT(A2), "Text", "Blank/Other"))

How it works

IS-functions classify the cell:

  1. ISNUMBER(A2) is TRUE for numbers (and dates); ISTEXT(A2) for text.
  2. Nest them in IF to route: do one thing for numbers, another for text, a fallback for blanks.
  3. This avoids errors — e.g. only multiply numeric cells, only UPPER text cells.
  4. Other testers: ISBLANK, ISLOGICAL, ISERROR — same pattern for those types.

One function for all: TYPE(A2) returns a code (1 number, 2 text, 4 logical, 16 error) you can SWITCH on. The IS-function approach is more readable for two or three branches.

Try it: interactive demo

Live demo

Type a value (number or text).

Handled as:

Variations

Only act on numbers

Guard math:

=IF(ISNUMBER(A2), A2*1.1, A2)

TYPE + SWITCH

Code-based:

=SWITCH(TYPE(A2), 1,"Num", 2,"Text", "Other")

Flag non-numbers

Audit:

=IF(NOT(ISNUMBER(A2)), "Check", "")

Pitfalls & errors

Dates are numbers. ISNUMBER is TRUE for dates and times — usually fine, but be aware.

Numbers stored as text. ISTEXT is TRUE for a “number” typed as text — which is exactly how you catch them.

Blanks. An empty cell is neither number nor text — handle it in the fallback branch.

Practice workbook

📊
Download the free Do Different Things for Text vs Numbers practice workbook
A type-routing sheet with the guard-math, TYPE+SWITCH, and audit variants, plus 4 challenges with answers. No sign-up required.

Frequently asked questions

How do I do different things for text vs numbers in Excel?
Branch on the type: =IF(ISNUMBER(A2), numberAction, IF(ISTEXT(A2), textAction, fallback)).
How do I only apply math to numeric cells?
Guard with ISNUMBER: =IF(ISNUMBER(A2), A2*1.1, A2) leaves text untouched.
Is there a single function that returns the type?
Yes — TYPE(A2) returns a code (1 number, 2 text, 4 logical, 16 error) you can SWITCH on.

Stop fighting formulas. Learn them in a day.

This recipe is one of hundreds of real-world formulas we teach. Our Excel Formulas & Functions class covers lookups, logic, text, and dynamic arrays hands-on — live in Dallas–Fort Worth, Houston, Austin, Oklahoma City, Denver, or online.

See the Formulas & Functions Class

Related formulas: ISNUMBER & ISTEXT · Check if a cell has an error · Convert text to number

Function references: ISNUMBER · ISTEXT