Empty/Delete Cells in a Column

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

Guest

Hello,

I've got three columns, A, B and C. Every cell in A is populated with a date
with the same month and year i.e. XX/08/2007 (dd/mm/yyyy). B and C also have
dates (not necessarily in every cell). What I would like to do is empty cells
in B and C that are not XX/08/2007 whether in the past or future.

Any help would be appreciated.
 
Sub removedates()

RowAMonth = Month(Range("A1"))
RowAYear = Year(Range("A1"))

Set BCRange = Range("B2:C20")

For Each cell In BCRange

If IsDate(cell) Then

If (Month(cell) <> RowAMonth) Or _
(Year(cell) <> RowAYear) Then

cell.ClearContents

End If
End If

Next cell

End Sub
 
Thank you Joel.

Joel said:
Sub removedates()

RowAMonth = Month(Range("A1"))
RowAYear = Year(Range("A1"))

Set BCRange = Range("B2:C20")

For Each cell In BCRange

If IsDate(cell) Then

If (Month(cell) <> RowAMonth) Or _
(Year(cell) <> RowAYear) Then

cell.ClearContents

End If
End If

Next cell

End Sub
 

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