Simple Clear Contents

  • Thread starter Thread starter Steph
  • Start date Start date
S

Steph

This seems so simple, but I can't figure it out.

In a large spreadsheet, I would like to ClearContents of the entire row IF
the contents in column D of each respective row is greater than the date
1/1/2005.

So in row 1, if D1 is > 1/1/2005, clear
In row 2, if D2 is > 1/1/2005, clear......

Thanks!
 
Dim rng as Range, cell as Range
set rng = Range(Cells(1,4),Cells(rows.count,4).End(xlup))
for each cell in rng
if isdate(cell) then
if cdate(cell.value) > DateSerial(2005,1,1) then
cell.EntireRow.ClearContents
end if
end if
Next
 

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