Thread: current year
View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
Sammy Sammy is offline
external usenet poster
 
Posts: 3
Default current year


"Rob" wrote in message
...
I wan to create a macro which will change the dates once a year to the
current year. I have a range of dates beginning with 01/01/2008 and I
want
to change these dates to the current year and I want to be able to run
this
macro each year to update the year that is in the cells to the current
year.
I can replace code but how do I state that to replace 200* with the
current
year. Please help...Thanks in advance.


Hi Rob

The variation I use, and find very useful, is below. Refer to the value of
either 'GetYear' or 'a'. This method using WorkBook_Activate() means that
EVERY time the Workbook opens the Year will be current, meaning you will
have no replacement to make.

-- Code

Private Sub Workbook_Activate()
Dim GetDate, GetYear

GetDate = Now
GetYear = Year(GetDate)
a = GetYear

[a1] = a '[##] = shorthand method of refering to cells
End Sub

--