I understand the title says it is for Excel but bear with me because the code is being run through Access.
I am exporting data to Excel to generate charts. I am about 98% done with this task but I am missing one chart that I am trying to base off a pivot because I do not know a better way to do it.
I can create the pivot fine and place the fields where I want them, I am just struggling to group the dates by month. I have browsed online and tried all the variations I have come across but none of them work. The code I am (attempting) to use is below. Any help will be infinitely appreciated.
I am exporting data to Excel to generate charts. I am about 98% done with this task but I am missing one chart that I am trying to base off a pivot because I do not know a better way to do it.
I can create the pivot fine and place the fields where I want them, I am just struggling to group the dates by month. I have browsed online and tried all the variations I have come across but none of them work. The code I am (attempting) to use is below. Any help will be infinitely appreciated.
Code:
Dim groupRange As Range
Set objTable = ws.PivotTableWizard
Set objField = objTable.PivotFields("Date")
Set groupRange = objField.DataRange
groupRange.Cells(2, 1).Group Periods:=Array(False, False, False, False, True, False, False)
objField.Orientation = xlColumnField