View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Tim Childs[_4_] Tim Childs[_4_] is offline
external usenet poster
 
Posts: 31
Default Help on Code Snippet Error {Val function}

hi

thks for that, and the suggested workaround. Very helpful
Tim

"joeu2004" wrote in message
...
"Tim Childs" wrote:
I thought the E04 was generating an exponential or something?


Almost right.

I did not notice the difference between "13 E04 01" and "13 G04 01".

Note that Val("13 45") is interpreted as Val("1345"). That is, Val
ignores spaces.

So the problem is: Val interprets "13 E04 01" as "13E401". That is
indeed an overflow insofar as it exceeds 1.79769313486232E+308 = (2^1023 -
2^(1023-53))*2.

If you want Val to stop on the first interstitial space, try:

Val(Replace(LTrim(RTrim(.Cells(iFirstDataRow, iTestCol))," ",","))