Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default check to see if all dates are for the current year

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


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default check to see if all dates are for the current year

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


--
Regards,
Tom Ogilvy

"Oldjay" wrote in message
...
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




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 337
Default check to see if all dates are for the current year

Thanks Works Great

oldjay

"Tom Ogilvy" wrote:

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


--
Regards,
Tom Ogilvy

"Oldjay" wrote in message
...
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





Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
convert existing range of dates to to current year, maintaining mm Lin24 New Users to Excel 4 October 27th 09 08:04 PM
When typing dates do not default to current year. Spreadsheet Geek[_2_] Excel Worksheet Functions 2 October 31st 07 09:28 PM
Converting Older Dates to Current Year Cristella Excel Worksheet Functions 2 October 23rd 07 11:36 PM
Combination Graph with current year and prior year sales JanW Charts and Charting in Excel 2 April 5th 07 09:20 PM
lock up rows w/dates diff than current year Myriam Excel Programming 0 October 13th 04 08:29 PM


All times are GMT +1. The time now is 04:00 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"