#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default ISNUMBER

Hi, does anyone know the best way to test if the 1st character in a cell in a
number or a letter in an IF statement? I tried =IF(ISNUMBER(MID(A1,1,1)),do
this if true, do this if false where A1 could be a202 or 202 and it didn't
work. I clearly don't understand the ISNUMBER command. I even tried it alone
=ISNUMBER(MID(A1,1,1) where A1 was a202 and 202 and they both came back
FALSE. Any ideas?

Thanks,
John
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 66
Default ISNUMBER

Try IsNumeric instead

hth

Geoff K

"johnrb7865" wrote:

Hi, does anyone know the best way to test if the 1st character in a cell in a
number or a letter in an IF statement? I tried =IF(ISNUMBER(MID(A1,1,1)),do
this if true, do this if false where A1 could be a202 or 202 and it didn't
work. I clearly don't understand the ISNUMBER command. I even tried it alone
=ISNUMBER(MID(A1,1,1) where A1 was a202 and 202 and they both came back
FALSE. Any ideas?

Thanks,
John

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 703
Default ISNUMBER

On 15 Jul., 23:46, johnrb7865
wrote:
Hi, does anyone know the best way to test if the 1st character in a cell in a
number or a letter in an IF statement? I tried =IF(ISNUMBER(MID(A1,1,1)),do
this if true, do this if false where A1 could be a202 or 202 and it didn't
work. I clearly don't understand the ISNUMBER command. I even tried it alone
=ISNUMBER(MID(A1,1,1) where A1 was a202 and 202 and they both came back
FALSE. *Any ideas?

Thanks,
John


Hi John

=isnumber(A1)

will return true if A1 contains a number, otherwise it returns false.

Regards,
Per
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default ISNUMBER

Mid returns a character which is not a number. try this. I used Left
instead orf mid but they are equivalent

=IF(AND(LEFT(A1,1)="0",LEFT(A1,1)<="9"),TRUE,FALS E)

"johnrb7865" wrote:

Hi, does anyone know the best way to test if the 1st character in a cell in a
number or a letter in an IF statement? I tried =IF(ISNUMBER(MID(A1,1,1)),do
this if true, do this if false where A1 could be a202 or 202 and it didn't
work. I clearly don't understand the ISNUMBER command. I even tried it alone
=ISNUMBER(MID(A1,1,1) where A1 was a202 and 202 and they both came back
FALSE. Any ideas?

Thanks,
John

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default ISNUMBER

=mid() will always return text.

=IF(ISNUMBER(-MID(A1,1,1))

If A1 contained A202, then -A would cause an error--not a number.

If A1 contained 202, then -2 (and the minus will coerce the text two to a number
two) and that's a number.


johnrb7865 wrote:

Hi, does anyone know the best way to test if the 1st character in a cell in a
number or a letter in an IF statement? I tried =IF(ISNUMBER(MID(A1,1,1)),do
this if true, do this if false where A1 could be a202 or 202 and it didn't
work. I clearly don't understand the ISNUMBER command. I even tried it alone
=ISNUMBER(MID(A1,1,1) where A1 was a202 and 202 and they both came back
FALSE. Any ideas?

Thanks,
John


--

Dave Peterson


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 66
Default ISNUMBER

The reason the formula failed is because the op id not complete the question
IF IsNumber = Something then do this do that. The construction of Mid works
just as well as Left as written.

Geoff K

"Joel" wrote:

Mid returns a character which is not a number. try this. I used Left
instead orf mid but they are equivalent

=IF(AND(LEFT(A1,1)="0",LEFT(A1,1)<="9"),TRUE,FALS E)

"johnrb7865" wrote:

Hi, does anyone know the best way to test if the 1st character in a cell in a
number or a letter in an IF statement? I tried =IF(ISNUMBER(MID(A1,1,1)),do
this if true, do this if false where A1 could be a202 or 202 and it didn't
work. I clearly don't understand the ISNUMBER command. I even tried it alone
=ISNUMBER(MID(A1,1,1) where A1 was a202 and 202 and they both came back
FALSE. Any ideas?

Thanks,
John

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default ISNUMBER

Thanks Joel, that worked great.

John

"Joel" wrote:

Mid returns a character which is not a number. try this. I used Left
instead orf mid but they are equivalent

=IF(AND(LEFT(A1,1)="0",LEFT(A1,1)<="9"),TRUE,FALS E)

"johnrb7865" wrote:

Hi, does anyone know the best way to test if the 1st character in a cell in a
number or a letter in an IF statement? I tried =IF(ISNUMBER(MID(A1,1,1)),do
this if true, do this if false where A1 could be a202 or 202 and it didn't
work. I clearly don't understand the ISNUMBER command. I even tried it alone
=ISNUMBER(MID(A1,1,1) where A1 was a202 and 202 and they both came back
FALSE. Any ideas?

Thanks,
John

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
If IsNumber Kitty[_3_] Excel Programming 4 August 8th 06 05:49 PM
ISNUMBER Michael Nol Excel Worksheet Functions 1 March 22nd 06 12:29 AM
ISNUMBER RJJ Excel Worksheet Functions 8 January 4th 06 11:29 PM
isnumber() mark kubicki Excel Programming 2 November 5th 04 04:25 AM
ISNumber VBA trickdos[_9_] Excel Programming 7 July 23rd 04 10:37 PM


All times are GMT +1. The time now is 03:16 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"