A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Excel » Worksheet Functions
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Does the cell have a number?



 
 
Thread Tools Display Modes
  #1  
Old January 25th, 2005, 07:53 PM
Fletcher
external usenet poster
 
Posts: n/a
Default Does the cell have a number?

I want a formula that will tell me if a given cell has a number in it, so it
evaluates the type of data. I looked in the help files and couldn't figure
this out.

Thanks,
Craig


  #2  
Old January 25th, 2005, 08:07 PM
LanceB
external usenet poster
 
Posts: n/a
Default

=ISNUMBER(a1)

"Fletcher" wrote:

I want a formula that will tell me if a given cell has a number in it, so it
evaluates the type of data. I looked in the help files and couldn't figure
this out.

Thanks,
Craig



  #3  
Old January 25th, 2005, 08:15 PM
Fletcher
external usenet poster
 
Posts: n/a
Default

I tried that, but if the cell has numbers and text, it replies back with
FALSE. I would like to be able to determine if any part of the cell contents
is a number, even if the string starts with, or contains letters.

Thanks!

"LanceB" wrote in message
...
=ISNUMBER(a1)

"Fletcher" wrote:

I want a formula that will tell me if a given cell has a number in it, so
it
evaluates the type of data. I looked in the help files and couldn't
figure
this out.

Thanks,
Craig





  #4  
Old January 25th, 2005, 09:24 PM
Gord Dibben
external usenet poster
 
Posts: n/a
Default

Fletcher

You could use a UDF

Function hasNumbers(myString As String) As Boolean
If myString Like "*[1234567890]*" Then
hasNumbers = True
Else
hasNumbers = False
End If
End Function

usage is: =hasNumbers(cellref)


Gord Dibben Excel MVP

On Tue, 25 Jan 2005 13:15:33 -0700, "Fletcher"
wrote:

I tried that, but if the cell has numbers and text, it replies back with
FALSE. I would like to be able to determine if any part of the cell contents
is a number, even if the string starts with, or contains letters.

Thanks!

"LanceB" wrote in message
...
=ISNUMBER(a1)

"Fletcher" wrote:

I want a formula that will tell me if a given cell has a number in it, so
it
evaluates the type of data. I looked in the help files and couldn't
figure
this out.

Thanks,
Craig





  #5  
Old January 25th, 2005, 09:54 PM
Rob van Gelder
external usenet poster
 
Posts: n/a
Default

=SUMPRODUCT(--(ABS(CODE(MID(A1, ROW(INDIRECT("1:" & LEN(A1))), 1)) -
52.5)=4.5))0

--
Rob van Gelder - http://www.vangelder.co.nz/excel


"Fletcher" wrote in message
...
I tried that, but if the cell has numbers and text, it replies back with
FALSE. I would like to be able to determine if any part of the cell
contents is a number, even if the string starts with, or contains letters.

Thanks!

"LanceB" wrote in message
...
=ISNUMBER(a1)

"Fletcher" wrote:

I want a formula that will tell me if a given cell has a number in it,
so it
evaluates the type of data. I looked in the help files and couldn't
figure
this out.

Thanks,
Craig







  #6  
Old January 25th, 2005, 10:51 PM
tjtjjtjt
external usenet poster
 
Posts: n/a
Default

Would you mind explaining why this formula works?
Thanks,
tj

"Rob van Gelder" wrote:

=SUMPRODUCT(--(ABS(CODE(MID(A1, ROW(INDIRECT("1:" & LEN(A1))), 1)) -
52.5)=4.5))0

--
Rob van Gelder - http://www.vangelder.co.nz/excel


"Fletcher" wrote in message
...
I tried that, but if the cell has numbers and text, it replies back with
FALSE. I would like to be able to determine if any part of the cell
contents is a number, even if the string starts with, or contains letters.

Thanks!

"LanceB" wrote in message
...
=ISNUMBER(a1)

"Fletcher" wrote:

I want a formula that will tell me if a given cell has a number in it,
so it
evaluates the type of data. I looked in the help files and couldn't
figure
this out.

Thanks,
Craig








  #7  
Old January 25th, 2005, 11:07 PM
Rob van Gelder
external usenet poster
 
Posts: n/a
Default

MID(A1, ROW(INDIRECT("1:" & LEN(A1))), 1) allows the string to be split into
individual entries
CODE(..) returns the ascii code for each character - I'm looking for numbers
which are in the range 48 to 57 for "0" to "9"
Then subtract 52.5, which is midway between 48 and 57 48+(57-48)/2 where
(57-48)/2 = 4.5
ABS turns negative numbers to positive. So this means ascii codes for
numbers are from 0 to 4.5
Check to see whether any of the numbers are less than or equal to 4.5 which
returns a series of TRUE/FALSE
-- turns TRUE, FALSE to 1, 0
SUMPRODUCT adds the entries of an array.
0 means the count of characters which were identified as numbers



--
Rob van Gelder - http://www.vangelder.co.nz/excel


"tjtjjtjt" wrote in message
...
Would you mind explaining why this formula works?
Thanks,
tj

"Rob van Gelder" wrote:

=SUMPRODUCT(--(ABS(CODE(MID(A1, ROW(INDIRECT("1:" & LEN(A1))), 1)) -
52.5)=4.5))0

--
Rob van Gelder - http://www.vangelder.co.nz/excel


"Fletcher" wrote in message
...
I tried that, but if the cell has numbers and text, it replies back with
FALSE. I would like to be able to determine if any part of the cell
contents is a number, even if the string starts with, or contains
letters.

Thanks!

"LanceB" wrote in message
...
=ISNUMBER(a1)

"Fletcher" wrote:

I want a formula that will tell me if a given cell has a number in
it,
so it
evaluates the type of data. I looked in the help files and couldn't
figure
this out.

Thanks,
Craig










  #8  
Old January 25th, 2005, 11:23 PM
tjtjjtjt
external usenet poster
 
Posts: n/a
Default

Thank you. It's quite clever.

tj

"Rob van Gelder" wrote:

MID(A1, ROW(INDIRECT("1:" & LEN(A1))), 1) allows the string to be split into
individual entries
CODE(..) returns the ascii code for each character - I'm looking for numbers
which are in the range 48 to 57 for "0" to "9"
Then subtract 52.5, which is midway between 48 and 57 48+(57-48)/2 where
(57-48)/2 = 4.5
ABS turns negative numbers to positive. So this means ascii codes for
numbers are from 0 to 4.5
Check to see whether any of the numbers are less than or equal to 4.5 which
returns a series of TRUE/FALSE
-- turns TRUE, FALSE to 1, 0
SUMPRODUCT adds the entries of an array.
0 means the count of characters which were identified as numbers



--
Rob van Gelder - http://www.vangelder.co.nz/excel


"tjtjjtjt" wrote in message
...
Would you mind explaining why this formula works?
Thanks,
tj

"Rob van Gelder" wrote:

=SUMPRODUCT(--(ABS(CODE(MID(A1, ROW(INDIRECT("1:" & LEN(A1))), 1)) -
52.5)=4.5))0

--
Rob van Gelder - http://www.vangelder.co.nz/excel


"Fletcher" wrote in message
...
I tried that, but if the cell has numbers and text, it replies back with
FALSE. I would like to be able to determine if any part of the cell
contents is a number, even if the string starts with, or contains
letters.

Thanks!

"LanceB" wrote in message
...
=ISNUMBER(a1)

"Fletcher" wrote:

I want a formula that will tell me if a given cell has a number in
it,
so it
evaluates the type of data. I looked in the help files and couldn't
figure
this out.

Thanks,
Craig











 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
I need to increase a number which is held in a cell by 1 Steve New Users 1 January 14th, 2005 12:07 PM
GET.CELL Biff Worksheet Functions 2 November 24th, 2004 07:16 PM
Cell -find number of columns unitl next non-blank cell. Joe Worksheet Functions 2 May 28th, 2004 08:50 PM
Convert a Cell Reference to Text Chuck Buker Worksheet Functions 6 September 22nd, 2003 05:04 PM


All times are GMT +1. The time now is 12:28 PM.


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