Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 28
Default problem creating a pivot table using a macro

I've been trying to create a macro that will create a pivot table
using an existing data matrix. I keep getting an error message as
follows: "Unable to get the PivotTables properties of the Worksheet
class" Here is the coding where the error occurs:

Sheets("Details").Select
Range("A1").Select
Selection.CurrentRegion.Select
ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatab ase,
SourceData:= _
"Details!R1C1:R8822C23").CreatePivotTable TableDestination:= _
"'[Import profile macros.xls]Pivotx'!R1C1",
TableName:="PivotTable14", _
DefaultVersion:=xlPivotTableVersion10
ActiveWorkbook.ShowPivotTableFieldList = True
With ActiveSheet.PivotTables("PivotTable14").PivotField s("Shipper
Name")
.Orientation = xlRowField
.Position = 1
End With

The error seems to occur on the With Activesheet...... line.

It seems that the macro can't locate the sheet where the pivot table
resides. This problem occurs whether I place the pivot table on a new
sheet or on an existing sheet. I have to admit that i am a neophyte
when it comes to writing Excel macros.

I appreciate any suggestions.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 149
Default problem creating a pivot table using a macro

Try changing

With ActiveSheet.PivotTables("PivotTable14").PivotField s("Shipper
Name")

to

With Worksheets("pivotx").PivotTables("PivotTable14").P ivotFields("Shipper
Name")

since that was the destination of the PivotTable you added.

HTH,

wrote in message
oups.com...
I've been trying to create a macro that will create a pivot table
using an existing data matrix. I keep getting an error message as
follows: "Unable to get the PivotTables properties of the Worksheet
class" Here is the coding where the error occurs:

Sheets("Details").Select
Range("A1").Select
Selection.CurrentRegion.Select
ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatab ase,
SourceData:= _
"Details!R1C1:R8822C23").CreatePivotTable TableDestination:= _
"'[Import profile macros.xls]Pivotx'!R1C1",
TableName:="PivotTable14", _
DefaultVersion:=xlPivotTableVersion10
ActiveWorkbook.ShowPivotTableFieldList = True
With ActiveSheet.PivotTables("PivotTable14").PivotField s("Shipper
Name")
.Orientation = xlRowField
.Position = 1
End With

The error seems to occur on the With Activesheet...... line.

It seems that the macro can't locate the sheet where the pivot table
resides. This problem occurs whether I place the pivot table on a new
sheet or on an existing sheet. I have to admit that i am a neophyte
when it comes to writing Excel macros.

I appreciate any suggestions.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 28
Default problem creating a pivot table using a macro

Many thanks for the suggestion! I made the change and was able to
advance further down the macro, but it now gets hung up on the
following statement:

End With
ActiveSheet.PivotTables("PivotTable14").AddDataFie ld
ActiveSheet.PivotTables( _
"PivotTable14").PivotFields("total cost for line item"), _
"Sum of total cost for line item", xlSum

I tried several variations to include ("pivotx") as was done earlier,
but none of these worked. Any suggestions?


On Mar 26, 4:06 pm, "George Nicholson"
wrote:
Try changing

With ActiveSheet.PivotTables("PivotTable14").PivotField s("Shipper
Name")

to

With Worksheets("pivotx").PivotTables("PivotTable14").P ivotFields("Shipper
Name")

since that was the destination of the PivotTable you added.

HTH,

wrote in message

oups.com...

I've been trying to create a macro that will create a pivot table
using an existing data matrix. I keep getting an error message as
follows: "Unable to get the PivotTables properties of the Worksheet
class" Here is the coding where the error occurs:


Sheets("Details").Select
Range("A1").Select
Selection.CurrentRegion.Select
ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatab ase,
SourceData:= _
"Details!R1C1:R8822C23").CreatePivotTable TableDestination:= _
"'[Import profile macros.xls]Pivotx'!R1C1",
TableName:="PivotTable14", _
DefaultVersion:=xlPivotTableVersion10
ActiveWorkbook.ShowPivotTableFieldList = True
With ActiveSheet.PivotTables("PivotTable14").PivotField s("Shipper
Name")
.Orientation = xlRowField
.Position = 1
End With


The error seems to occur on the With Activesheet...... line.


It seems that the macro can't locate the sheet where the pivot table
resides. This problem occurs whether I place the pivot table on a new
sheet or on an existing sheet. I have to admit that i am a neophyte
when it comes to writing Excel macros.


I appreciate any suggestions.



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I detail Pivot Table data without creating a table (Excel2007) Skeletiko[_2_] Excel Discussion (Misc queries) 1 May 5th 10 08:22 AM
How can I detail Pivot Table data without creating a table (Excel2007) Skeletiko Excel Discussion (Misc queries) 0 May 5th 10 12:21 AM
Creating Pivot Tables with macro Problem Linda Excel Programming 4 November 2nd 05 07:19 PM
Help with a macro creating a formula for a pivot table Valeria Excel Programming 1 November 20th 04 12:40 AM
Creating a pivot table from different sets of data using a macro Éidhne in Ireland Excel Programming 1 November 21st 03 05:20 PM


All times are GMT +1. The time now is 05:14 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"