Comparing Text to Numeric Vals

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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:
 
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"
<[email protected]>
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:
 
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
 
Back
Top