Pivot Table macro problems

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

kmarsden

Thread Starter
Joined
Mar 13, 2009
Messages
2
I have a macro that creates a pivot table from data on a worksheet. The problem I have is that I want the pivot table created on the same worksheet as the data. Anyone know how I can do this?

The code is below.........

Sub Macro6()
'

ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase, SourceData:= _
Worksheets("Raw Data").Range("C1").CurrentRegion).CreatePivotTable _
TableDestination:="Raw Data", TableName:="PivotTable1", _
DefaultVersion:=xlPivotTableVersion10
ActiveWorkbook.ShowPivotTableFieldList = True
With ActiveSheet.PivotTables("PivotTable1").PivotFields("Error Code")
.Orientation = xlRowField
.Position = 1
End With
ActiveSheet.PivotTables("PivotTable1").AddDataField ActiveSheet.PivotTables( _
"PivotTable1").PivotFields("Description"), "Count of Description", xlCount
ActiveWorkbook.ShowPivotTableFieldList = False
Application.CommandBars("PivotTable").Visible = False
ActiveSheet.Range("E1").Select
ActiveSheet.Range("A1").Select
End Sub
 
Joined
Jul 1, 2005
Messages
8,546
I can't run your code, I have an earlier version.

You have a (partial) line:

TableDestination:="Raw Data"

When I record pivot table creation & specify same sheet, I get:

TableDestination:=Range("G1")

, so try something like that. Of course you'll need to be sure that the destination is a "safe" area.

ETA: welcome to the board.
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 807,865 other people just like you!

Latest posts

Staff online

Members online

Top