George_Martin_3
New Member
- Joined
- Sep 12, 2015
- Messages
- 20
Rich (BB code):
Rich (BB code):
Sub OrderPivot()'Create a pivot table table in new worksheet from table1
Dim sht As Worksheet
Dim pvtCache As PivotCache
Dim pvt As PivotTable
Dim StartPvt As String
Dim SrcData As String
'Determine source data range as table1
SrcData = ActiveSheet.Name & "!" & Range("Table1").Address(ReferenceStyle:=xlR1C1)
'Create a new worksheet
Set sht = Sheets.Add
'Pivot table starts at A3 in new worksheet
StartPvt = sht.Name & "!" & sht.Range("A3").Address(ReferenceStyle:=xlR1C1)
'Create Pivot Cache from Source Data
Set pvtCache = ActiveWorkbook.PivotCaches.Create( _
SourceType:=xlDatabase, _
SourceData:=SrcData)
'Create Pivot table from Pivot Cache
Set pvt = pvtCache.CreatePivotTable( _
TableDestination:=StartPvt, _
TableName:="PivotTable1")
End Sub
The error is bug is occurring at 'Create Pivot table from Pivot Cache
Mac Excel 2011