row (i:j).select
Rows(i & ":" & j).Select
Usually when deleting rows, it is best to loop from the bottom up.
as you can see, if you deleted i = 2 and j = 3, then you add 1 to each, you
are now at row 3 and 4, but these are really the old 5 and 6 (the old 4 gets
skipped)
If you are deleting duplicate rows in a sorted list
last row = cells(rows.count,1).End(xlup)
for i = lastrow to 1 step -1
if cells(i,1).Value = cells(i-1,1).Value then
rows(i).Delete
end if
Next
You are deleting both rows, so I am not sure exactly what your doing, but
maybe the above will provide some ideas.
--
Regards,
Tom Ogilvy
"ina" wrote:
Hello,
I have this piece of code: I would like to input in row.select the
range of the row.
cell = Range("A" + CStr(i)).Value
cell2 = Range("A" + CStr(j)).Value
If (cell) = (cell2) And (cell) < " " Then
Rows("""i + ":" + j""").Select
Selection.Delete Shift:=xlUp
Else
i = i + 1
j = j + 1
End If
I have a problem in rows statement.
Thank you
Ina
|