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 _ |
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 _ |
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 _ |
All times are GMT +1. The time now is 04:59 PM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com