View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Jim Cone Jim Cone is offline
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 _