ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   ISNULL( ) or something else... (https://www.excelbanter.com/excel-programming/343365-isnull-something-else.html)

shane

ISNULL( ) or something else...
 
I am having trouble making my macro run properly. The problem is happening
around the area with "!!!"

Public Sub assign()
Worksheets("Sheet3").Activate
Dim xnode As Long
Dim zrow As Long
zrow = 2
xnode = 1
Do While Range("B" & zrow).Value < 0
Range("A" & zrow).Value = xnode
xnode = xnode + 1
If Range("E" & zrow).Value < 0 Then
Range("D" & zrow).Value = xnode
xnode = xnode + 1
End If
' !!!
If Range("I" & zrow).Value < 0 Then
Range("H" & zrow).Value = xnode
xnode = xnode + 1
End If
' !!!

zrow = zrow + 1
Loop
End Sub

I am wanting it to put variable xnode into column H at row zrow. However, I
only want it to do this IF the cell in column I row zrow is not empty.

The result is that a value is put into H regardless of whether I has any
values in it or not.

Please help. Thanks.


Bob Phillips[_6_]

ISNULL( ) or something else...
 
Have you tried

If Range("I" & zrow).Value < "" Then

or

If IsEmpty(Range("I" & zrow).Value) Then

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Shane" wrote in message
...
I am having trouble making my macro run properly. The problem is

happening
around the area with "!!!"

Public Sub assign()
Worksheets("Sheet3").Activate
Dim xnode As Long
Dim zrow As Long
zrow = 2
xnode = 1
Do While Range("B" & zrow).Value < 0
Range("A" & zrow).Value = xnode
xnode = xnode + 1
If Range("E" & zrow).Value < 0 Then
Range("D" & zrow).Value = xnode
xnode = xnode + 1
End If
' !!!
If Range("I" & zrow).Value < 0 Then
Range("H" & zrow).Value = xnode
xnode = xnode + 1
End If
' !!!

zrow = zrow + 1
Loop
End Sub

I am wanting it to put variable xnode into column H at row zrow. However,

I
only want it to do this IF the cell in column I row zrow is not empty.

The result is that a value is put into H regardless of whether I has any
values in it or not.

Please help. Thanks.




Zack Barresse

ISNULL( ) or something else...
 
Change this line ...

If Range("I" & zrow).Value < 0 Then

... to this ...

If Range("I" & zrow).Value < "" Then

HTH

--
Regards,
Zack Barresse, aka firefytr, (GT = TFS FF Zack)



"Shane" wrote in message
...
I am having trouble making my macro run properly. The problem is happening
around the area with "!!!"

Public Sub assign()
Worksheets("Sheet3").Activate
Dim xnode As Long
Dim zrow As Long
zrow = 2
xnode = 1
Do While Range("B" & zrow).Value < 0
Range("A" & zrow).Value = xnode
xnode = xnode + 1
If Range("E" & zrow).Value < 0 Then
Range("D" & zrow).Value = xnode
xnode = xnode + 1
End If
' !!!
If Range("I" & zrow).Value < 0 Then
Range("H" & zrow).Value = xnode
xnode = xnode + 1
End If
' !!!

zrow = zrow + 1
Loop
End Sub

I am wanting it to put variable xnode into column H at row zrow. However,
I
only want it to do this IF the cell in column I row zrow is not empty.

The result is that a value is put into H regardless of whether I has any
values in it or not.

Please help. Thanks.




Tom Ogilvy

ISNULL( ) or something else...
 
Just to add to the excellent suggestions

If the change is

If Range("I" & zrow).Text < "" Then

then it should work in xl97 as well although I can think of some other
drawbacks - but they should be rare

another would be

If Not IsEmpty(Range("I" & zrow)) then



--
Regards,
Tom Ogilvy

"Zack Barresse" wrote in message
...
Change this line ...

If Range("I" & zrow).Value < 0 Then

.. to this ...

If Range("I" & zrow).Value < "" Then

HTH

--
Regards,
Zack Barresse, aka firefytr, (GT = TFS FF Zack)



"Shane" wrote in message
...
I am having trouble making my macro run properly. The problem is

happening
around the area with "!!!"

Public Sub assign()
Worksheets("Sheet3").Activate
Dim xnode As Long
Dim zrow As Long
zrow = 2
xnode = 1
Do While Range("B" & zrow).Value < 0
Range("A" & zrow).Value = xnode
xnode = xnode + 1
If Range("E" & zrow).Value < 0 Then
Range("D" & zrow).Value = xnode
xnode = xnode + 1
End If
' !!!
If Range("I" & zrow).Value < 0 Then
Range("H" & zrow).Value = xnode
xnode = xnode + 1
End If
' !!!

zrow = zrow + 1
Loop
End Sub

I am wanting it to put variable xnode into column H at row zrow.

However,
I
only want it to do this IF the cell in column I row zrow is not empty.

The result is that a value is put into H regardless of whether I has any
values in it or not.

Please help. Thanks.






shane

ISNULL( ) or something else...
 
Thank you for the help. I tried another similiar method shortly after
posting. I changed the "0" to Empty. It works now. Thanks!

"Tom Ogilvy" wrote:

Just to add to the excellent suggestions

If the change is

If Range("I" & zrow).Text < "" Then

then it should work in xl97 as well although I can think of some other
drawbacks - but they should be rare

another would be

If Not IsEmpty(Range("I" & zrow)) then



--
Regards,
Tom Ogilvy

"Zack Barresse" wrote in message
...
Change this line ...

If Range("I" & zrow).Value < 0 Then

.. to this ...

If Range("I" & zrow).Value < "" Then

HTH

--
Regards,
Zack Barresse, aka firefytr, (GT = TFS FF Zack)



"Shane" wrote in message
...
I am having trouble making my macro run properly. The problem is

happening
around the area with "!!!"

Public Sub assign()
Worksheets("Sheet3").Activate
Dim xnode As Long
Dim zrow As Long
zrow = 2
xnode = 1
Do While Range("B" & zrow).Value < 0
Range("A" & zrow).Value = xnode
xnode = xnode + 1
If Range("E" & zrow).Value < 0 Then
Range("D" & zrow).Value = xnode
xnode = xnode + 1
End If
' !!!
If Range("I" & zrow).Value < 0 Then
Range("H" & zrow).Value = xnode
xnode = xnode + 1
End If
' !!!

zrow = zrow + 1
Loop
End Sub

I am wanting it to put variable xnode into column H at row zrow.

However,
I
only want it to do this IF the cell in column I row zrow is not empty.

The result is that a value is put into H regardless of whether I has any
values in it or not.

Please help. Thanks.








All times are GMT +1. The time now is 10:08 AM.

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