Sub GroupPivotDates(InPivTable As Excel.PivotTable, strMonthOrQuarter As String)
Dim xlPivDateField As Excel.PivotField, xlGroupRange As Excel.Range
Set xlPivDateField = InPivTable.PivotFields("Dates")
Set xlGroupRange = xlPivDateField.DataRange
If strMonthOrQuarter = "Month" Then
xlGroupRange.Cells(1).Group Periods:= _
Array(False, False, False, False, True, False, True)
Else
xlGroupRange.Cells(1).Group Periods:= _
Array(False, False, False, False, False, True, True)
End If
Set xlPivDateField = Nothing
Set xlGroupRange = Nothing
End Sub
Dim xlPivDateField As Excel.PivotField, xlGroupRange As Excel.Range
Set xlPivDateField = InPivTable.PivotFields("Dates")
Set xlGroupRange = xlPivDateField.DataRange
If strMonthOrQuarter = "Month" Then
xlGroupRange.Cells(1).Group Periods:= _
Array(False, False, False, False, True, False, True)
Else
xlGroupRange.Cells(1).Group Periods:= _
Array(False, False, False, False, False, True, True)
End If
Set xlPivDateField = Nothing
Set xlGroupRange = Nothing
End Sub