H
Hru48
Hey,
I’m having a lot of trouble with pivot tables. I am trying to get
macro to create them automatically by taking data from one sheet an
making a pivot table in another (‘SheetRef’).
I can get it to work if I create a blank sheet for each new pivot b
changing the table destination to “”. But when I try to specify that
want them to be created on a specific sheet I get an error.
I have been trying to put the sheet name in the table desitnation:
ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase, SourceData:= _
"'01'!R8C1:R477C2").CreatePivotTable TableDestination:= HERE
_
TableName:="PivotTable1"
Am I doing something wrong? If someone can point me in the righ
direction I would really appreciate it. I have put the whole recordin
of createing th pivot underneath if that helps?
Cheers
Hayley
Range("A8:B8").Select
Range(Selection, Selection.End(xlDown)).Select
ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase, SourceData:
_
"'01'!R8C1:R477C2").CreatePivotTabl
TableDestination:=Range("G1"), _
TableName:="PivotTable1"
ActiveSheet.PivotTables("PivotTable1").SmallGrid = False
With ActiveSheet.PivotTables("PivotTable1").PivotFields("Agen
Number/Name")
.Orientation = xlRowField
.Position = 1
End With
With ActiveSheet.PivotTables("PivotTable1").PivotFields("Campaig
Type")
.Orientation = xlDataField
.Position = 1
End With
Application.CommandBars("PivotTable").Visible = False
End Su
I’m having a lot of trouble with pivot tables. I am trying to get
macro to create them automatically by taking data from one sheet an
making a pivot table in another (‘SheetRef’).
I can get it to work if I create a blank sheet for each new pivot b
changing the table destination to “”. But when I try to specify that
want them to be created on a specific sheet I get an error.
I have been trying to put the sheet name in the table desitnation:
ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase, SourceData:= _
"'01'!R8C1:R477C2").CreatePivotTable TableDestination:= HERE
_
TableName:="PivotTable1"
Am I doing something wrong? If someone can point me in the righ
direction I would really appreciate it. I have put the whole recordin
of createing th pivot underneath if that helps?
Cheers
Hayley
Range("A8:B8").Select
Range(Selection, Selection.End(xlDown)).Select
ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase, SourceData:
_
"'01'!R8C1:R477C2").CreatePivotTabl
TableDestination:=Range("G1"), _
TableName:="PivotTable1"
ActiveSheet.PivotTables("PivotTable1").SmallGrid = False
With ActiveSheet.PivotTables("PivotTable1").PivotFields("Agen
Number/Name")
.Orientation = xlRowField
.Position = 1
End With
With ActiveSheet.PivotTables("PivotTable1").PivotFields("Campaig
Type")
.Orientation = xlDataField
.Position = 1
End With
Application.CommandBars("PivotTable").Visible = False
End Su