Andy has attended:
Access Introduction course
Excel VBA Intro Intermediate course
Functions
Pivot tables
RE: Functions
Andy
Below is the code to create a pivot table in VBA
====================
Sub CreatePivot()
Dim DataRange As Range
Dim Destination As Range
Dim PvtTable As PivotTable
Set Destination = Sheets("Sales Summary").Range("A12")
Set DataRange = Range("A9", Range("J9").End(xlDown))
ActiveSheet.PivotTableWizard SourceType:=xlDatabase, _
SourceData:=DataRange, TableDestination:=Destination, TableName:="SalesInfo"
Application.CommandBars("PivotTable").Visible = False 'Hides toolbar
ActiveWorkbook.ShowPivotTableFieldList = False 'Hides Field List
Set PvtTable = Sheets("Sales Summary").PivotTables("SalesInfo")
With PvtTable
.PivotFields(