ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Searching for Value. (https://www.excelbanter.com/excel-programming/390030-searching-value.html)

Miaplacidus

Searching for Value.
 


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?







Gary''s Student

Searching for Value.
 
Try an empty test instead of a numerical test:

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

--
Gary''s Student - gsnu200723


"Miaplacidus" wrote:



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?







Dave Peterson

Searching for Value.
 
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.

Miaplacidus wrote:

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?


--

Dave Peterson

Miaplacidus

Searching for Value.
 
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.







"Gary''s Student" wrote:

Try an empty test instead of a numerical test:

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

--
Gary''s Student - gsnu200723


"Miaplacidus" wrote:



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?







Miaplacidus

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





"Dave Peterson" wrote:

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.

Miaplacidus wrote:

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?


--

Dave Peterson


Dave Peterson

Searching for Value.
 
The extra debug statement didn't help?

Sorry, I don't have another guess.

Miaplacidus wrote:

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

"Dave Peterson" wrote:

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.

Miaplacidus wrote:

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?


--

Dave Peterson


--

Dave Peterson


All times are GMT +1. The time now is 12:10 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com