How to continue loop after deleting row?
So you are now calculating lc and using that?
--
HTH
Bob Phillips
(remove nothere from email address if mailing direct)
wrote in message
ups.com...
Bob Phillips wrote:
lr = rows(selection.row+selection.rows.count-1)
for i = lr to selection.row step -1
For j = 1 To Cels(i,Columns.Count).End(xlToLeft).Column
if cells(i,j).Value = 'condition based on cell.value' then
cells(i,j).entireRow.delete
Thanks. That is close. But cells(i,columns.count) refers
to the last non-empty cell in the row, not the last cell of in
the selection, as I would want. So I think I should iterate
j from 1 to "lc", whose value is:
lc = columns(selection.column + selection.columns.count - 1).column
Although your suggestion is sufficient for my immediate
problem (thanks), it does not exactly answer my question.
I wrote:
for each cell in selection ' n-by-m area
if 'condition based on cell.value' then
cell.entireRow.delete
else
' process cell
end if
next
[....]
Is there an easy way to continue the loop by processing
(the new) A2 after deleting row 2?
You suggest processing the selection in reverse order,
from highest to lowest row number. I agree that would be
most efficient, and it would work in cases where processing
order does not matter.
But there are cases where the rows must be processed
from lowest to highest number.
So I am still interested in a solution that addresses my
original question as stated.
|