View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Debra Dalgleish Debra Dalgleish is offline
external usenet poster
 
Posts: 2,979
Default 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