Conditional Format to Delete Row

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a conditional format that turns the cell red if today date is 45 days
greater thatn the date in the cell. If the cell is red, how can I delete the
entire row automatically?
 
Assume the date is held in column F

Dim lastRow as Long, i as Long
lastrow = cells(rows.count,"F").End(xlup).row
for i = lastrow to 2 step -1
if clng(Date) > clng(cells(lastrow,"F").Value2) + 45 then
rows(i).Delete
end if
Next

so check the condition. It is extremely difficult to check the color of a
cell colored by conditional formatting.
 
I would think that you would use the same cell you're applying the
conditional formatting from to determine if it should be deleted. Ex.

If Range("A6").Formula = DateAdd("d", -45, Date()) Then
Range("6:6").Select
Selection.Delete Shift:=xlUp
End If
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top