shieldsco
asked on
Excel VBA Error
I'm using the code below and receive run-time error 1004 unable to get the pivot field property of the Pivot Table Class on line - Set rngGroup = PvtTbl.PivotFields("Dates" ).DataRang e
Sub PivotTableGroupData1()
Dim PvtTbl As PivotTable
Dim rngGroup As Range
Set PvtTbl = Worksheets("Data Chart").PivotTables("PivotTable1")
'set range of dates to be grouped
Set rngGroup = PvtTbl.PivotFields("Dates").DataRange
rngGroup.Cells(1).Group Periods:=Array(False, False, False, False, True, False, False)
'to ungroup:
'rngGroup.Cells(1).Ungroup
End Sub
Can you provide an excel file example with a manual pivotable that is corresponding to your needs
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
Thanks
ASKER
Thanks