Searching for Value.

G

Guest

I've got code:

for each c in range ....

If c.value > 0 then

DoCode

End If
Next C



This was working fine, but suddenly it is executing Do Code whne c is blank.

What is wrong here.

When I test is Isnumeric returns true
The value returns blank and the length returns zero.


What gives?
 
G

Guest

Try an empty test instead of a numerical test:

Sub emptest()
If IsEmpty(Selection) Then
MsgBox ("empty")
End If
End Sub
 
D

Dave Peterson

Maybe you're on the wrong cell.

You could add a debugging line:

msgbox c.address & vblf & c.value & len(c.value)

To help find the problem cell.
 
G

Guest

Thanks. I'll try it, although I think I did that. I think the problem was
that isempty returns "false" although there is nothing in the cell I can
find: not a blank space, and not an empty string, and not a number less than
..5, Nothing.

So how can the value be greater than zero? I tried greater than 1, and it
still runs.

The situation is that I have a bunch of rows with data in month coumns
(Yeah, I know. It wasn't my design, but I'm stuck with it.) and most months
are empty, so the code should skip over them. Sometimes it does, but
sometimes it finds something in the cell and reports out zero or blank data.
That then, causes other problems later. I'm sure that I am looking at the
right cell. Even if I'm not, the same problem happens multiple times in
adjacent cells.

Normally when I hover over a variable the value is shown, but for some
reason, that isnt working either. Or wasn't. Now it seems to be back on
again. For at least one case it reported a null string "". So I put in a
test for that, and now it seems to work.

ALSO, the help section says isempty only returns meaningful information for
type variant. Also the help says that isnumber, istext, and isnontext should
be available, but when I try them I get an error statement saying it isn't a
valid function. This whole problem would go away if isnumber() worked.

Any other ideas? I know this has to be a common problem.
 
G

Guest

Nope. I'm certain I'm on the right cell. Still can't get the advertized Excel
functions to work in VBA.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top