Hi Guys,
I'm using the below function which turns a week number into a week
I use it to return the date 25 weeks from now
when I load the macro on another machine I noticed I was getting a different date
when running the following:
my machine returned the correct result which is Week 45 yet on my other machine it returns a result of week 46
could someone please help me find out what is causing this issue?
many thanks
I'm using the below function which turns a week number into a week
Code:
Public Function Week2Date(WeekNo As Long) As Date
Dim Jan1 As Date
Dim Sub1 As Boolean
Dim Ret As Date
Jan1 = DateSerial(Year(Date), 1, 1)
'Sub1 = (VBA.Format(Jan1, "ww", VBA.vbMonday, VBA.vbFirstFourDays) = 1)
Sub1 = (Format(Jan1, "ww", vbUseSystem, vbUseSystem) = 1)
Ret = DateAdd("ww", WeekNo + Sub1, Jan1)
Ret = Ret - WeekDay(Ret) + 7
Week2Date = Ret
End Function
I use it to return the date 25 weeks from now
Code:
dateweek = DateValue((Week2Date((Format(Now, "ww") + 25))))
when running the following:
Code:
dateweek = DateValue((Week2Date((Format(Now, "ww")))))
could someone please help me find out what is causing this issue?
many thanks