Starting a For Loop from the last Row and going upwards.
If you delete the row while you're traversing the rows, it becomes a pain.
But you could build a range to delete in the loop and then delete it later:
dim c as range
dim delRng as range
For Each c In masterTrackerWs.Range("C2:C" & masterTrackerWs_lastRow).Cells
If c.Offset(0, 1).Text = "#N/A" _
And c.Offset(0, 2).Text = "#N/A" Then
if delrng is nothing then
set delrng = c
else
set delrng = union(c, delrng)
end if
End If
Next c
if delrng is nothing then
delrng.entirerow.delete
end if
Ayo wrote:
If I wanted this for loop to start from the bottom row, how do I go about
doing that. I want the row deletion to start from the last row going upwards.
For Each c In masterTrackerWs.Range("C2:C" & masterTrackerWs_lastRow).Cells
If c.Offset(0, 1).Text = "#N/A" And c.Offset(0, 2).Text = "#N/A" Then
c.EntireRow.Delete
End If
Next c
--
Dave Peterson
|