drpdrpdrp
New Member
- Joined
- Sep 9, 2021
- Messages
- 22
- Office Version
- 2019
- 2016
- Platform
- Windows
The following VBA UDF returns a 4-value-array using a Date value as input. Even though it is simple, if I ran for ~10'000 rows calculation time is not satisfactory (>30seconds).
What am I doing wrong and how should I write the code to make it faster?
What am I doing wrong and how should I write the code to make it faster?
VBA Code:
' YrMoDoy
Function YrMoDoyDom(InputDate)
Dim Yr As Variant
Dim Mo As Variant
Dim Doy As Variant
Dim Woy As Variant
Yr = Year(InputDate)
Mo = Month(InputDate)
Doy = InputDate - DateSerial(Year(InputDate), 1, 0)
Dom = Day(InputDate)
'Woy = WorksheetFunction.IsoWeek(InputDate)
YrMoDoyDom = Array(Yr, Mo, Doy, Dom)
End Function