ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Easy Loop question (with delete row) (https://www.excelbanter.com/excel-programming/400564-easy-loop-question-delete-row.html)

Mike R.

Easy Loop question (with delete row)
 
Hi -
This is driving me crazy. Can someone assist with this formula? It is
comparing the date on sheet "Pending List" to a static date on "Data" and if
it is less that the Data date, it will delete the row.

Thanks a bunch.

For iloop = irows To 2 Step -1
If Sheets("Pending List").Range("C" & iloop).Value <
Sheets("Data").Range("D19").Value Then Sheets("Pending List").Cells(iloop,
3).EntireRow.Delete
Next iloop


OssieMac

Easy Loop question (with delete row)
 
Hi Mike,

Your code is missing an End if (Perhaps that is only due to copying the code
to here because if that is your problem then you should have got an error
message accordingly). Otherwise the code tests fine.

Check that you have valid dates and not text values in both
Sheets("Data").Range("D19") and in Sheets("Pending List").

Next test that irows is a valid value for the range you are testing. Insert
the following before the loop as follows:-

MsgBox "irows = " & irows

For iloop = irows To 2 Step -1
If Sheets("Pending List").Range("C" & iloop).Value _
< Sheets("Data").Range("D19").Value Then _
Sheets("Pending List").Cells(iloop, 3).EntireRow.Delete
End If
Next iloop

Also if irows and iloop are likely to be greater than 32000 ensure they are
not dimensioned as integers.

Regards,

OssieMac





"Mike R." wrote:

Hi -
This is driving me crazy. Can someone assist with this formula? It is
comparing the date on sheet "Pending List" to a static date on "Data" and if
it is less that the Data date, it will delete the row.

Thanks a bunch.

For iloop = irows To 2 Step -1
If Sheets("Pending List").Range("C" & iloop).Value <
Sheets("Data").Range("D19").Value Then Sheets("Pending List").Cells(iloop,
3).EntireRow.Delete
Next iloop


Mike R.

Easy Loop question (with delete row)
 
perfect...it works great. thanks!

"OssieMac" wrote:

Hi Mike,

Your code is missing an End if (Perhaps that is only due to copying the code
to here because if that is your problem then you should have got an error
message accordingly). Otherwise the code tests fine.

Check that you have valid dates and not text values in both
Sheets("Data").Range("D19") and in Sheets("Pending List").

Next test that irows is a valid value for the range you are testing. Insert
the following before the loop as follows:-

MsgBox "irows = " & irows

For iloop = irows To 2 Step -1
If Sheets("Pending List").Range("C" & iloop).Value _
< Sheets("Data").Range("D19").Value Then _
Sheets("Pending List").Cells(iloop, 3).EntireRow.Delete
End If
Next iloop

Also if irows and iloop are likely to be greater than 32000 ensure they are
not dimensioned as integers.

Regards,

OssieMac





"Mike R." wrote:

Hi -
This is driving me crazy. Can someone assist with this formula? It is
comparing the date on sheet "Pending List" to a static date on "Data" and if
it is less that the Data date, it will delete the row.

Thanks a bunch.

For iloop = irows To 2 Step -1
If Sheets("Pending List").Range("C" & iloop).Value <
Sheets("Data").Range("D19").Value Then Sheets("Pending List").Cells(iloop,
3).EntireRow.Delete
Next iloop



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

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