DutchKevin
Board Regular
- Joined
- Apr 13, 2011
- Messages
- 133
- Office Version
- 365
- Platform
- Windows
Hello All,
I'm using a UDF to get from a yyyyww notation to a real date. I take the yyyy value from a cell, use it in ISOYEARSTART and then add 7 times the number of weeks from the same cell
I add 5 days, to end up on a friday, which is may target day of that week.
Although all this works fine, what would be the way to adapt the UDF to avoid the second part of the formula?
I'd like to get it into one UDF for easy references.
Any Advice?
Any other setup is also welcome, avoiding the yearstart maybe and going straight for the date?
Note: I must use ISO weeknumbers because of european standards. And I use european notation, hence the ; in stead of the , in the formula's.
This is the ISOYEARSTART code
I'm using a UDF to get from a yyyyww notation to a real date. I take the yyyy value from a cell, use it in ISOYEARSTART and then add 7 times the number of weeks from the same cell
Code:
=IFERROR(IF(A3=0;"";ISOYEARSTART(LEFT(A3;4))+7*RIGHT(A3;2))+5;"")
Although all this works fine, what would be the way to adapt the UDF to avoid the second part of the formula?
I'd like to get it into one UDF for easy references.
Any Advice?
Any other setup is also welcome, avoiding the yearstart maybe and going straight for the date?
Note: I must use ISO weeknumbers because of european standards. And I use european notation, hence the ; in stead of the , in the formula's.
This is the ISOYEARSTART code
Code:
Public Function ISOYEARSTART(WhichYear As Integer) As Date
' First published by John Green, Excel MVP, Sydney, Australia
Dim WeekDay As Integer
Dim NewYear As Date
NewYear = DateSerial(WhichYear, 1, 1)
WeekDay = (NewYear - 2) Mod 7
If WeekDay < 4 Then
ISOYEARSTART = NewYear - WeekDay
Else
ISOYEARSTART = NewYear - WeekDay + 7
End If
End Function
Last edited: