check to see if all dates are for the current year

  • Thread starter Thread starter Oldjay
  • Start date Start date
O

Oldjay

I have a col of dates. I wish to check to be sure they are all for the
current year and if any incorrect ones are found then change them to the
current year

oldjay
 
Assuming you just want to change the year. Tailor to fit your needs.

Sub ABC()
Dim rng as Range, cell as Range
set rng = Range(cells(1,"C"),cells(rows.count,"C").End(xlup))
for each cell in rng
if year(cell.Value) <> year(date) then
cell.Value = dateSerial(year(date),month(cell),day(cell))
end if
Next
End Sub
 
Thanks Works Great

oldjay

Tom Ogilvy said:
Assuming you just want to change the year. Tailor to fit your needs.

Sub ABC()
Dim rng as Range, cell as Range
set rng = Range(cells(1,"C"),cells(rows.count,"C").End(xlup))
for each cell in rng
if year(cell.Value) <> year(date) then
cell.Value = dateSerial(year(date),month(cell),day(cell))
end if
Next
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