Hello,
Currently, I have VBA code that filters data from a dataset and creates PivotTables with a click of a button. It works great but I was informed that the date of the transaction must also be a part of the PivotTable. This seemed easy but, when manually dragging and dropping the "Date" field into the Rows area, it auto adds 2 extra fields, "Months (Date)" and "Days (Date)". When trying to add the "Date" field through VBA though, it only adds "Date" and doesn't auto add the other two.
With that being said, is there a way to add those other 2 fields? Ultimately, I want the pivot table to only contain "Months (Date)", meaning the data is separated by the month, this means that I need to either hide or delete the "Date" & "Days (Date)" fields.
If it helps, the date is formatted as a short date and the VBA code I used to add the Date col to the pivot table is ".PivotFields("Date").Orientation = xlRowField".
I also tried adding .PivotFields("Months (Date)")... but I got errors saying it couldn't find the field.
Thanks for the help!
Currently, I have VBA code that filters data from a dataset and creates PivotTables with a click of a button. It works great but I was informed that the date of the transaction must also be a part of the PivotTable. This seemed easy but, when manually dragging and dropping the "Date" field into the Rows area, it auto adds 2 extra fields, "Months (Date)" and "Days (Date)". When trying to add the "Date" field through VBA though, it only adds "Date" and doesn't auto add the other two.
With that being said, is there a way to add those other 2 fields? Ultimately, I want the pivot table to only contain "Months (Date)", meaning the data is separated by the month, this means that I need to either hide or delete the "Date" & "Days (Date)" fields.
If it helps, the date is formatted as a short date and the VBA code I used to add the Date col to the pivot table is ".PivotFields("Date").Orientation = xlRowField".
I also tried adding .PivotFields("Months (Date)")... but I got errors saying it couldn't find the field.
Thanks for the help!