ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Distinguish Letters vs. Numbers in an IF Statement (https://www.excelbanter.com/excel-discussion-misc-queries/238605-distinguish-letters-vs-numbers-if-statement.html)

William Wolfe

Distinguish Letters vs. Numbers in an IF Statement
 
I need to write an IF statement so that if the contents of a cell are a
letter do one thing, it they are a number do another.

How do I distinguish between the two in an IF statement?

Thanks,

W. Wolfe



ExcelBanter AI

Answer: Distinguish Letters vs. Numbers in an IF Statement
 
Hi W. Wolfe,

To distinguish between letters and numbers in an IF statement, you can use the ISNUMBER function and the ISTEXT function.

Here's an example of how you can use these functions in an IF statement:
  1. =IF(ISNUMBER(A1), "Do something if it's a number", IF(ISTEXT(A1), "Do something if it's a letter", "Do something else if it's neither a number nor a letter"))

In this example, A1 is the cell you want to check. The first part of the IF statement checks if A1 contains a number using the ISNUMBER function. If it does, the statement returns "Do something if it's a number". If it doesn't, the second part of the IF statement checks if A1 contains a letter using the ISTEXT function. If it does, the statement returns "Do something if it's a letter". If A1 contains neither a number nor a letter, the statement returns "Do something else if it's neither a number nor a letter".

Mike H

Distinguish Letters vs. Numbers in an IF Statement
 
Hi,

Try this

=IF(ISNUMBER(A1),"Do number things",IF(NOT(ISBLANK(A1)),"Do text things","Do
neither, it's blank"))

Mike

"William Wolfe" wrote:

I need to write an IF statement so that if the contents of a cell are a
letter do one thing, it they are a number do another.

How do I distinguish between the two in an IF statement?

Thanks,

W. Wolfe




Ron Rosenfeld

Distinguish Letters vs. Numbers in an IF Statement
 
On Fri, 31 Jul 2009 14:34:04 -0400, "William Wolfe"
wrote:

I need to write an IF statement so that if the contents of a cell are a
letter do one thing, it they are a number do another.

How do I distinguish between the two in an IF statement?

Thanks,

W. Wolfe


=if(isnumber(cell_ref),"do this","do that")
--ron

Rick Rothstein

Distinguish Letters vs. Numbers in an IF Statement
 
Use the ISNUMBER function...

=IF(A1="","I'm blank",IF(ISNUMBER(A1),"I'm a number","I'm text"))

--
Rick (MVP - Excel)


"William Wolfe" wrote in message
...
I need to write an IF statement so that if the contents of a cell are a
letter do one thing, it they are a number do another.

How do I distinguish between the two in an IF statement?

Thanks,

W. Wolfe



William Wolfe

Distinguish Letters vs. Numbers in an IF Statement
 
Thanks for your quick response.

W. Wolfe


"Rick Rothstein" wrote in message
...
Use the ISNUMBER function...

=IF(A1="","I'm blank",IF(ISNUMBER(A1),"I'm a number","I'm text"))

--
Rick (MVP - Excel)


"William Wolfe" wrote in message
...
I need to write an IF statement so that if the contents of a cell are a
letter do one thing, it they are a number do another.

How do I distinguish between the two in an IF statement?

Thanks,

W. Wolfe





gcnew

Great answers thank you, I have a question relating to this.
 
I love these answers! thank you that is so very helpful.

I have been searching for something like this but with a twist.

What if you have numbers and letters in the cell. is there a way to tell it to show just the letters or the numbers as the answer???

thank you

PS: I did not want to start a whole new thread, I will hopefully get the answer here.
if not I will start one another time.


All times are GMT +1. The time now is 01:58 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com