Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
DJS DJS is offline
external usenet poster
 
Posts: 31
Default Comparing Text to Numeric Vals

hello~

I am looking for the proper method to compare non-numeric (text) vals to
numeric vals.
Is there a way to modify the script so that if cell.Value was a text val it
could be
interpreted as a numeric val?
Something like: Number(cell.Value) in my script:

If cell.Offset(0, -1) < cell.Value And Not _


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default Comparing Text to Numeric Vals

DJS,

The Val function will return 0 if the cell value is non-numeric.
So if...Range("A1").Value = 10 and Range("A2").Value = "Butter"

Dim x as Double
x = (Range("A1").Value - Val(Range("A2").Value ))

(x will equal 10)

Jim Cone
San Francisco, USA


"DJS"

wrote in message
.
hello~
I am looking for the proper method to compare non-numeric (text) vals to
numeric vals.
Is there a way to modify the script so that if cell.Value was a text val it
could be
interpreted as a numeric val?
Something like: Number(cell.Value) in my script:
If cell.Offset(0, -1) < cell.Value And Not _


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 158
Default Comparing Text to Numeric Vals

I'm not quite sure if you mean compare 1 with "one" or 1 with "1a".

If you mean the latter, take a look at Val.

e.g. 21 = Val("21 tum ti tum") would evaluate to true.

HTH,
Gareth

DJS wrote:
hello~

I am looking for the proper method to compare non-numeric (text) vals to
numeric vals.
Is there a way to modify the script so that if cell.Value was a text val it
could be
interpreted as a numeric val?
Something like: Number(cell.Value) in my script:


If cell.Offset(0, -1) < cell.Value And Not _



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
Why do I get #NUM! for a GEOMEAN calc on a set of positive vals Nick Curties Excel Worksheet Functions 14 June 25th 07 01:42 PM
Numeric in Text to convert back to the form of Numeric for VLookup Purposes achilles Excel Discussion (Misc queries) 4 February 6th 06 07:05 AM
How get rid of these errors if cell has no vals? Jay Excel Worksheet Functions 3 March 4th 05 08:07 PM
Max of integer vals jbl25[_2_] Excel Programming 0 September 30th 04 03:03 PM
Max of integer vals jbl25 Excel Programming 3 September 30th 04 02:19 AM


All times are GMT +1. The time now is 01:45 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"