Hi,
I just can't get me head around what is probably an easy solution.
The code below is a date inputter into a sheet that on workbook open but only triggers if it's a new day. It inputs the current season, year, week number and day.
What I need is for when the week number gets to 27, the year is incremented by 1. As it currently stands, when it gets to 27 it WILL increment by 1 but then when it's a new day, it will increment again which I do not want to happen, in theory it should only increment every year.
How can I work around this?
Thanks
I just can't get me head around what is probably an easy solution.
The code below is a date inputter into a sheet that on workbook open but only triggers if it's a new day. It inputs the current season, year, week number and day.
What I need is for when the week number gets to 27, the year is incremented by 1. As it currently stands, when it gets to 27 it WILL increment by 1 but then when it's a new day, it will increment again which I do not want to happen, in theory it should only increment every year.
How can I work around this?
Thanks
Code:
Private Sub Workbook_Open()
CurrentSeason = Evaluate("=IF(" & [WeekCell] & "<27,""AW"",""SS"")") '' AW = Weeks 1 - 26, SS = Weeks 27 - 52/53
CurrentWeek = Evaluate("=WEEKNUM(TODAY()-246,1)") '' Company week 1 is offset from global calendar week 1
CurrentDay = Evaluate("=TEXT(TODAY()-1, ""dddd"")") '' Reporting day
If CurrentDay <> [DayCell] Then '' Allows code to only run when it's a new day
If MsgBox("Do you want to update the date?", vbYesNo) = vbYes Then
[SeasonCell] = CurrentSeason
'[WeekCell] = CurrentWeek
If [WeekCell] = 27 Then '' This logic needs changing
CurrentYear = [YearCell] + 1
Else
CurrentYear = [YearCell]
End If
[YearCell] = CurrentYear
'[DayCell] = CurrentDay
End If
End If
End Sub