The tutorial explains what ISNUMBER in Excel is and provides examples of basic and advanced uses.
The concept of the ISNUMBER function in Excel is very simple - it just checks whether a given value is a number or not. An important point here is that the practical uses of the function go far beyond its basic concept, especially when combined with other functions within larger formulas.
Excel ISNUMBER function
The ISNUMBER function in Excel checks if a cell contains a numerical value or not. It belongs to the group of IS functions.
The function is available in all versions of Excel for Office 365, Excel 2019, Excel 2016, Excel 2013, Excel 2010, Excel 2007 and lower.
The ISNUMBER syntax requires just one argument:
=ISNUMBER(value)
Where value is the value you want to test. Usually, it is represented by a cell reference, but you can also supply a real value or nest another function inside ISNUMBER to check the result.
If value is numeric, the function returns TRUE. For anything else (text values, errors, blanks) ISNUMBER returns FALSE.
As an example, let's test values in cells A2 through A6, and we will find out that the first 3 values are numbers and the last two are text:
2 things you should know about ISNUMBER function in Excel
There are a couple of interesting points to note here:
- In internal Excel representation, dates and times are numeric values, so the ISNUMBER formula returns TRUE for them (please see B3 and B4 in the screenshot above).
- For numbers stored as text, the ISNUMBER function returns FALSE (see this example).
Excel ISNUMBER formula examples
The below examples demonstrate a few common and a couple of non-trivial uses of ISNUMBER in Excel.
Check if a value is number
When you have a bunch of values in your worksheet and you want to know which ones are numbers, ISNUMBER is the right function to use.
In this example, the first value is in A2, so we use the below formula to check it, and then drag down the formula to as many cells as needed:
=ISNUMBER(A2)
Please pay attention that although all the values look like numbers, the ISNUMBER formula has returned FALSE for cells A4 and A5, which means those values are numeric strings, i.e. numbers formatted as text. There may be different reasons for this, for example leading zeros, preceding apostrophe, etc. Whatever the reason, Excel does not recognize such values as numbers. So, if your values do not calculate correctly, the first thing for you to check is whether they are really numbers in terms of Excel, and then convert text to number if needed.
Excel ISNUMBER SEARCH formula
Apart from identifying numbers, the Excel ISNUMBER function can also check if a cell contains specific text as part of the content. For this, use ISNUMBER together with the SEARCH function.
In the generic form, the formula looks as follows:
Where substring is the text that you want to find.
As an example, let's check whether the string in A3 contains a specific color, say red:
=ISNUMBER(SEARCH("red", A3))
This formula works nicely for a single cell. But because our sample table (please see below) contains three different colors, writing a separate formula for each one would be the waste of time. Instead, we will refer to the cell containing the color of interest (B2).
=ISNUMBER(SEARCH(B$2, $A3))
For the formula to correctly copy down and to the right, be sure to lock the following coordinates with the $ sign:
- In substring reference, lock the row (B$2) so that the copied formulas always pick the substrings in row 2. The column reference is relative because we want it to adjust for each column, i.e. when the formula is copied to C3, the substring reference will change to C$2.
- In the source cell reference, lock the column ($A3) so that all the formulas check the values in column A.
The screenshot below shows the result:
ISNUMBER FIND - case-sensitive formula
As the SEARCH function is case-insensitive, the above formula does not differentiate uppercase and lowercase characters. If you are looking for a case-sensitive formula, use the FIND function rather than SEARCH.
For our sample dataset, the formula would take this form:
=ISNUMBER(FIND(B$2, $A3))
How this formula works
The formula's logic is quite obvious and easy to follow:
- The SEARCH / FIND function looks for the substring in the specified cell. If the substring is found, the position of the first character is returned. If the substring is not found, the function produces a #VALUE! error.
- The ISNUMBER function takes it from there and processes numeric positions. So, if the substring is found and its position is returned as a number, ISNUMBER outputs TRUE. If the substring is not found and a #VALUE! error occurs, ISNUMBER outputs FALSE.
IF ISNUMBER formula
If you aim to get a formula that outputs something other than TRUE or FALSE, use ISNUMBER together with the IF function.
Example 1. Cell contains which text
Taking the previous example further, suppose you want to mark the color of each item with "x" like shown in the table below.
To have this done, simply wrap the ISNUMBER SEARCH formula into the IF statement:
=IF(ISNUMBER(SEARCH(B$2, $A3)), "x", "")
If ISNUMBER returns TRUE, the IF function outputs "x" (or any other value you supply to the value_if_true argument). If ISNUMBER returns FALSE, the IF function outputs an empty string ("").
Example 2. First character in a cell is number or text
Imagine that you are working with a list of alphanumeric strings and you want to know whether a string's first character is a number or letter.
To build such a formula, we you'll need 4 different functions:
- The LEFT function extracts the first character from the start of a string, say in cell A2:
LEFT(A2, 1)
- Because LEFT belongs to the category of Text functions, its result is always a text string, even if it only contains numbers. Therefore, before checking the extracted character, we need to try to convert it to a number. For this, use either the VALUE function or double unary operator:
VALUE(LEFT(A2, 1))
or(--LEFT(A2, 1))
- The ISNUMBER function determines if the extracted character is numeric or not:
ISNUMBER(VALUE(LEFT(A2, 1)))
- Based on the ISNUMBER result (TRUE or FALSE), the IF function returns "Number" or "Letter", respectively.
Assuming we are testing a string in A2, the complete formula takes this shape:
=IF(ISNUMBER(VALUE(LEFT(A2, 1))), "Number", "Letter")
or
=IF(ISNUMBER(--LEFT(A2, 1)), "Number", "Letter")
The ISNUMBER function also comes in handy for extracting numbers from a string. Here's an example: Get number from any position in a string.
Check if a value is not number
Though Microsoft Excel has a special function, ISNONTEXT, to determine whether a cell's value is not text, an analogous function for numbers is missing.
An easy solution is to use ISNUMBER in combination with NOT that returns the opposite of a logical value. In other words, when ISNUMBER returns TRUE, NOT converts it to FALSE, and the other way round.
To see it in action, please observe the results of the following formula:
=NOT(ISNUMBER(A2))
Another approach is using the IF and ISNUMBER functions together:
=IF(ISNUMBER(A2), "", "Not number")
If A2 is numeric, the formula returns nothing (an empty string). If A2 is not numeric, the formula says it upfront: "Not number".
If you'd like to perform some calculations with numbers, then put an equation or another formula in the value_if_true argument instead of an empty string. For example, the below formula will multiply numbers by 10 and yield "Not number" for non-numeric values:
=IF(ISNUMBER(A2), A2*10, "Not number")
Check if a range contains any number
In situation when you want to test the whole range for numbers, use the ISNUMBER function in combination with SUMPRODUCT like this:
For example, to find out if the range A2:A5 contains any numeric value, the formulas would go as follows:
=SUMPRODUCT(--ISNUMBER(A2:A5))>0
=SUMPRODUCT(ISNUMBER(A2:A5)*1)>0
If you'd like to output "Yes" and "No" instead of TRUE and FALSE, utilize the IF statement as a "wrapper" for the above formulas. For example:
=IF(SUMPRODUCT(--ISNUMBER(A2:A5))>0, "Yes", "No")
How this formula works
At the heart of the formula, the ISNUMBER function evaluates each cell of the specified range, say B2:B5, and returns TRUE for numbers, FALSE for anything else. As the range contains 4 cells, the array has 4 elements:
{TRUE;FALSE;FALSE;FALSE}
The multiplication operation or the double unary (--) coerces TRUE and FALSE into 1's and 0's, respectively:
{1;0;0;0}
The SUMPRODUCT function adds up the elements of the array. If the result is greater than zero, that means there is at least one number the range. So, you use ">0" to get a final result of TRUE or FALSE.
ISNUMBER in conditional formatting to highlight cells that contain certain text
If you are looking to highlight cells or entire rows that contain specific text, create a conditional formatting rule based on the ISNUMBER SEARCH (case-insensitive) or ISNUMBER FIND (case-sensitive) formula.
For this example, we are going to highlight rows based on the value in column A. More precisely, we will highlight the items that contain the word "red". Here's how:
- Select all the data rows (A2:C6 in this example) or only the column in which you want to highlight cells.
- On the Home tab, in the Styles group, click New Rule > Use a formula to determine which cells to format.
- In the Format values where this formula is true box, enter the below formula (please notice that the column coordinate is locked with the $ sign):
=ISNUMBER(SEARCH("red", $A2))
- Click the Format button and choose the format you want.
- Click OK twice.
If you have little experience with Excel conditional formatting, you can find the detailed steps with screenshots in this tutorial: How to create a formula-based conditional formatting rule.
As the result, all the items of the red color are highlighted:
Instead of "hardcoding" the color in the conditional formatting rule, you can type it in a predefined cell, say E2, and refer to that cell in your formula (please mind the absolute cell reference $E$2). Additionally, you need to check if the input cell is not empty:
=AND(ISNUMBER(SEARCH($E$2, $A2)), $E$2<>"")
As the result, you will get a more flexible rule that highlights rows based on your input in E2:
That's how to use the ISNUMBER function in Excel. I thank you for reading and hope to see you on our blog next week!
63 comments
Can anyone help with this expression?
let cell A1 = x,
for x = 1, change the number to 9,
x = 2, change the number to 8,
x = 3, change the number to 7,
Input: 312
Output: 798
Hello John!
To extract all the digits from a number one by one, use MID function. Use CHOOSE function to replace these digits with other characters or numbers.
Use CONCAT function to combine these digits into a text string.
Based on the information given, the formula could be as follows:
=CONCAT(IFERROR(CHOOSE(--MID(A1,ROW(INDIRECT("1:"&LEN(A1))),1),9,8,7,6,5,4,3,2,1),0))
hello Mr. Trifuntov, thank you very much for the quick response. The thing is I am referring to only one cell.
So lets say I put cell A1 the value of 312. Base on the expression, each number has an equivalent code number.
So,
We have 312 in cell A1 while the code number should be in cell B1 which is 798.
Thank you.
Hi! If you write the proposed formula in cell B1, you will get exactly the result you are writing about.
I don't know what version of Excel you have, but try entering this formula as an array formula.
Hello, Thank you very much. Now I understand. It is actually the version of excel. Again thank you. I got it. Very helpful. Thanks
It actually works upgrading to newer version of excel.
Can you please let me understand the formula?
Thank you.
Hi! Let’s break down the formula step by step:
1. LEN(A1): LEN function returns the length of the string in cell A1. For example, if A1 contains “312”, LEN(A1) returns 3.
2. INDIRECT("1:"&LEN(A1)): INDIRECT function creates a reference to a range of numbers from 1 to the length of the string in A1. For “312”, it generates the array {1, 2, 3}.
3. ROW(INDIRECT("1:"&LEN(A1))): This returns the row numbers of the range created by INDIRECT. For “312”, it results in the array {1, 2, 3}.
4. MID(A1, ROW(INDIRECT("1:"&LEN(A1))), 1): The MID function extracts each character from the string in A1, one by one. For “312”, it produces the array {“3”, “1”, “2”}.
5. --MID(A1, ROW(INDIRECT("1:"&LEN(A1))), 1): The double unary operator -- converts the text characters to numbers. So, {“3”, “1”, “2”} becomes {3, 1, 2}.
6. CHOOSE(--MID(A1, ROW(INDIRECT("1:"&LEN(A1))), 1), 9, 8, 7, 6, 5, 4, 3, 2, 1): CHOOSE function selects a value from the list based on the index provided. Here, it maps each digit to a corresponding value from the list {9, 8, 7, 6, 5, 4, 3, 2, 1}. For {3, 1, 2}, it returns {7, 9, 8}.
7. IFERROR(..., 0): IFERROR function handles any errors that might occur in the previous steps, replacing them with 0. In this case, there are no errors, so it remains {7, 9, 8}.
8. CONCAT(...): Finally, the CONCAT function joins the array elements into a single string. So, {7, 9, 8} becomes “798”.
In summary, the formula transforms each digit in the input string “312” to a corresponding value from the list {9, 8, 7, 6, 5, 4, 3, 2, 1} and concatenates the results to form “798”.
Array formulas are available in all versions of Excel. Don't forget to use CTRL + SHIFT + ENTER in older Excel versions.
Brilliant. Thank you.
I tried using the formula in google spreadsheet and I encountered error. Does it means it won't work on spreadsheet?
Hi! Array formulas in Google spreadsheet work differently than in Excel.
Please if I have column barcodes each barcode is 13 digit
And have cell include 10 digit
What function can use to find this 10 digit in column ?
Hi! You can find a partial match of text strings using the MATCH formula and the SEARCH function. The formula returns the number of the position where a partial match was found.
=MATCH(TRUE,ISNUMBER(SEARCH(B1,A1:A10)),0)
For more information, please read: How to find substring in Excel
I am looking to expand on this Excel Equation. This equation works, but it doesn't put in Past Due for item that are over 6 months. There is an Initial Inspection Date which is column C, list in this format, 2023-11-30 and column N being the column compared to in the format 2023-11 because we only care about the month and year. N1= 2023-11, N2= 2023-06 and N3=2023-07
=IF((ISNUMBER(SEARCH($N$1,$C2))),(IF(ISNUMBER(SEARCH($O$1,$D2)),"Move to In-Process",$D2)),(IF((ISNUMBER(SEARCH($N$2,$C2))),"Move to Close",$D2)))
Is there a way to add the below equation into the above equation to make it work?
(IF((ISNUMBER(SEARCH($N$3,$C2))),"Past Due",$D2))
N3, I have add and is not part of the original table. Can someone help me with figuring out how to expand my equation to put in "Past Due" when the item is over 6 months out from the Initial Inspection Date?
Hi! If I understand the problem correctly, you can add another nested IF function. For more information, please read: Nested IF in Excel – formula with multiple conditions.
=IF((ISNUMBER(SEARCH($N$1,$C2))), IF(ISNUMBER(SEARCH($O$1,$D2)),"Move to In-Process",$D2), IF((ISNUMBER(SEARCH($N$2,$C2))),"Move to Close", IF((ISNUMBER(SEARCH($N$3,$C2))),"Past Due",$D2)))
Hi!
I am trying to find two formulas:
-One that can count if the leftmost character of an entry is any letter or the number 1.
-The other formula should just count entries starting with another number (0, 2, 3, 4, 5, 6, 7, 8, 9; or perhaps just '0')
Do you have any idea how to achieve this?
I am currently using a formula from another post https://www.ablebits.com/office-addins-blog/create-multi-select-dropdown-excel/
with great results, but I can't think of how to implement the above into it.
=SUMPRODUCT(--ISNUMBER(SEARCH("";range))
Rgds
J
Hi! Select the first character from the text string using the LEFT function and check it using this formula:
=SUM((LEFT(A1:A10,1)="1")+(NOT(ISNUMBER(--LEFT(A1:A10,1)))))
HI! I am using the following formula to search for specific number in text, in this case for "65" in cell G8: =IF(ISNUMBER(SEARCH("65",G8)),"65"). The formula, however, tells me also when number 65 is part of different numbers such "165, 650,...". How can i obtain number "65" when "65" stands alone and it is not part of another number? Thank you!
Hi! If your number stands alone, try adding spaces to the search string.
IF(ISNUMBER(SEARCH(" 65 ",G8)),"65")
Hi There
=IF(ISNUMBER(FIND("65",G8)),"65").