dan_l
Active Member
So this UDF returns a date as a serial. Every time I run it over my data set, I just right click and format the cells as date, and go on with my pivot tables. That's fine, but I wonder if it's possible to return the value as a formatted date.
I tried format([serial],"MMDDYYYY"), but that bring it back as text (and the pivot table can't group those values.
[pre]
[/pre]
I tried format([serial],"MMDDYYYY"), but that bring it back as text (and the pivot table can't group those values.
[pre]
Code:
Function YYYYMMDDcnv(target As Range)
Dim year As Integer
Dim month As Integer
Dim day As Integer
Dim dc As Date
year = Left(target, 4)
day = Right(target, 2)
month = Mid(target, 5, 2)
dc = DateSerial(year, month, day)
YYYYMMDDcnv = dc
End Function