View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
GS[_6_] GS[_6_] is offline
external usenet poster
 
Posts: 1,182
Default Strange behaviour - empty cell being evaluated as numeric

Hi there,

Wonder if anyone can tell me what might be going on here.

I have a routine that check a column of values row by row, cell by
cell for various undesirable conditions which if it finds it ends the
sub and highlights the offending cell to allow the user to correct
it.

It is a series of doubles which I have dimmed as variant, and it
checks to see if its numeric, empty or 0.5.

What has happened is that one data entry person has messed up
somewhat and entered the numbers in wrongly and to fix it I just
entered a formula in excel to turn any cells that were too big into
the right number by dividing by 100, and if the cell was empty to
give it and empty string value ("").

What is happening is that when it is evaluation an empty cell, it is
throwing an error for the condition 0.5 which is very puzzling
indeed since it is an empty string.

If I select the offending cell and clear all, then it solves it and
the cell is evaluated correctly.

I cannot see why this happens as if it is a string then why would it
be evaluated as .05

Any ideas?

Thanks and regards, Mark


Well.., possibly because the var is variant and so VBA interprets "" as
a string and 0.5 as numeric and so should throw a type mismatch error.
This is common when trying to process the empty string with numeric
values. Perhaps return zero?

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion