I was able to figure this out. Here is the code.
Sub WeeklyReportStep8()
'Pivot Table creation
Dim PTCache As PivotCache
Dim PT As PivotTable
Dim PF As PivotField
'Create the Cache
Set PTCache = ActiveWorkbook.PivotCaches.Create( _
SourceType:=xlDatabase, _
SourceData:=Range("A1").CurrentRegion)
'Add a new sheet for the pivot table
Worksheets.Add
Application.ScreenUpdating = False
'Create the pivot table
Set PT = ActiveSheet.PivotTables.Add( _
PivotCache:=PTCache, _
TableDestination:=Range("A3"))
PT.RowAxisLayout xlTabularRow
PT.ShowDrillIndicators = False
PT.ColumnGrand = False
PT.RowGrand = False
'specify fields to be grouped
With PT
.PivotFields("Grade 1").Orientation = xlRowField
End With
Dim rPTRange As Range
Set PF = PT.RowFields("Grade 1")
Set rPTRange = PF.DataRange.Cells(1, 1)
rPTRange.Group Start:=True, End:=100, By:=15
With PT
.PivotFields("Grade 1").Orientation = xlHidden
End Sub
End With
Bookmarks