T
tehwa
I have a piece of mcro code that is giving me grief, but I cannot fin
the error in the logic:
The purpose is to loop through the second column until there is no mor
data in the column, searching for nulls. If there is a null in a cel
from that column, the row needs to be deleted. But it will not detec
consecutive null cells, so it is only deleting every second row that
want it to.
'Find the end of the range, to set the bounds of th
function:
Dim areaCount As Integer
Columns(1).Select
ActiveCell.CurrentRegion.Select
areaCount = Selection.Rows.Count
Dim counter As Integer
'Loop through from (1, 2) to (end, 2) deleting rows with null in th
cells.
For counter = 1 To areaCount
If Cells(counter, 2).Value = 0 Then
Rows(counter).Delete
End If
Next counter
So it should be going:
Is (1, 2) null? Nope. Next cell.
Is (2,2) null? Nope, Next cell
Is (3, 2) null? Yep, Delete the row. Next Cell...
If anyone can tell me where I am going wrong here, or just paste
working algorithm I would be very grateful.
.tehw
the error in the logic:
The purpose is to loop through the second column until there is no mor
data in the column, searching for nulls. If there is a null in a cel
from that column, the row needs to be deleted. But it will not detec
consecutive null cells, so it is only deleting every second row that
want it to.
'Find the end of the range, to set the bounds of th
function:
Dim areaCount As Integer
Columns(1).Select
ActiveCell.CurrentRegion.Select
areaCount = Selection.Rows.Count
Dim counter As Integer
'Loop through from (1, 2) to (end, 2) deleting rows with null in th
cells.
For counter = 1 To areaCount
If Cells(counter, 2).Value = 0 Then
Rows(counter).Delete
End If
Next counter
So it should be going:
Is (1, 2) null? Nope. Next cell.
Is (2,2) null? Nope, Next cell
Is (3, 2) null? Yep, Delete the row. Next Cell...
If anyone can tell me where I am going wrong here, or just paste
working algorithm I would be very grateful.
.tehw