ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   pivot table destination (https://www.excelbanter.com/excel-programming/285358-pivot-table-destination.html)

douvid

pivot table destination
 
Hi,
Is it possible to create a pivot table on a new sheet but to choose its position ? Like you can choose when it is on the same worksheet.
Is it with .CreatePivotTable TableDestination:="" ?

Cheers,
Douvid


Debra Dalgleish

pivot table destination
 
The following code creates a new sheet, and creates the PT at cell A3:

'=============================
Sub PivotTableNewSheet()
Dim ws1 As Worksheet
Dim wsNew As Worksheet
Set ws1 = ActiveSheet
Set wsNew = Worksheets.Add

ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatab ase, _
SourceData:="Database").CreatePivotTable _
TableDestination:=wsNew.Range("A3"), _
TableName:="PivotTable1"
wsNew.PivotTables("PivotTable1").AddFields _
RowFields:="Year", ColumnFields:="Region"
wsNew.PivotTables("PivotTable1").PivotFields("Unit s") _
.Orientation = xlDataField
ws1.Select
End Sub
'=============================

Douvid wrote:
Hi,
Is it possible to create a pivot table on a new sheet but to choose its position ? Like you can choose when it is on the same worksheet.
Is it with .CreatePivotTable TableDestination:="" ?

Cheers,
Douvid



--
Debra Dalgleish
Excel FAQ, Tips & Book List
http://www.contextures.com/tiptech.html



All times are GMT +1. The time now is 04:16 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com