Michael M
Well-known Member
- Joined
- Oct 27, 2005
- Messages
- 21,872
- Office Version
- 365
- 2019
- 2013
- 2007
- Platform
- Windows
Hi All
This is my first post to this site. I used to post on the Office online site but my administrators decided to restrict my access.
My question is:
I would like the code below to refer the Pivot table to the current Active sheet NOT "'[TESTEquipInv_0506.xls]Oct05 WBS'!R6C20" as shown in the code.
Any advice would be appreciated
Regards
Michael M
Option Explicit
Sub PIVOT()
'
ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase, SourceData:= _
"R1C6:R57C17").CreatePivotTable TableDestination:= _
"'[TESTEquipInv_0506.xls]Oct05 WBS'!R6C20", TableName:="PivotTable2", _
DefaultVersion:=xlPivotTableVersion10
ActiveWorkbook.ShowPivotTableFieldList = True
Application.CommandBars("PivotTable").Visible = False
With ActiveSheet.PivotTables("PivotTable2").PivotFields("WBS Element")
.Orientation = xlRowField
.Position = 1
End With
ActiveSheet.PivotTables("PivotTable2").AddDataField ActiveSheet.PivotTables( _
"PivotTable2").PivotFields("Allocation"), "Sum of Allocation", xlSum
ActiveWorkbook.ShowPivotTableFieldList = False
Range("T6").Select
End Sub
This is my first post to this site. I used to post on the Office online site but my administrators decided to restrict my access.
My question is:
I would like the code below to refer the Pivot table to the current Active sheet NOT "'[TESTEquipInv_0506.xls]Oct05 WBS'!R6C20" as shown in the code.
Any advice would be appreciated
Regards
Michael M
Option Explicit
Sub PIVOT()
'
ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase, SourceData:= _
"R1C6:R57C17").CreatePivotTable TableDestination:= _
"'[TESTEquipInv_0506.xls]Oct05 WBS'!R6C20", TableName:="PivotTable2", _
DefaultVersion:=xlPivotTableVersion10
ActiveWorkbook.ShowPivotTableFieldList = True
Application.CommandBars("PivotTable").Visible = False
With ActiveSheet.PivotTables("PivotTable2").PivotFields("WBS Element")
.Orientation = xlRowField
.Position = 1
End With
ActiveSheet.PivotTables("PivotTable2").AddDataField ActiveSheet.PivotTables( _
"PivotTable2").PivotFields("Allocation"), "Sum of Allocation", xlSum
ActiveWorkbook.ShowPivotTableFieldList = False
Range("T6").Select
End Sub