Hello
It is my first post as usually I can find answer in existing post. But since two days I get crazy with my problem.
With VBA, I want to select some specific dates in a pivot table field. Hereunder my example
All the dates are stored in a table with a date format dd-mmm-yy (eg: 14-Mar-22)
To explain my problem I wrote this piece of code :
The problem ? For the first dates until march I get the right day - Day(Pi) - (23, 25, 29, ...) but starting the value '01/04/2022' the day is wrong as it says 4 instead of 1, 5, 8..
=> OK
=> KO
If someone has an idea, he/she is welcome !
Thank you very much for your help
It is my first post as usually I can find answer in existing post. But since two days I get crazy with my problem.
With VBA, I want to select some specific dates in a pivot table field. Hereunder my example
All the dates are stored in a table with a date format dd-mmm-yy (eg: 14-Mar-22)
To explain my problem I wrote this piece of code :
VBA Code:
Set pt = Sheets("tcd non reçus").PivotTables("PT_non_recu")
' change field as needed
Set pf = pt.PivotFields("expected date")
For Each Pi In pf.PivotItems
If Pi.Value <> "NULL" And Pi.Value <> "#N/A" And Not IsError(Pi.Value) Then
MsgBox Pi.Value & " - Day=" & Day(Pi)
End If
Next Pi
The problem ? For the first dates until march I get the right day - Day(Pi) - (23, 25, 29, ...) but starting the value '01/04/2022' the day is wrong as it says 4 instead of 1, 5, 8..
If someone has an idea, he/she is welcome !
Thank you very much for your help