Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 45
Default Problem with a recorded macro to create two pivot tables from same data

All:

I recorded a macro to create two pivot tables. I create the second table
by
copying the first, moving over two columns, paste the data, and them go
into the layout to change the data and column fields.
When I run the macro it gives me a run time error listed below. How do I

change the code to create the second table and fields like I did when I
record it?

Columns("A:B").Select
Selection.Copy
Range("C1").Select
ActiveSheet.Paste
Range("C7").Select
Application.CutCopyMode = False
ActiveSheet.PivotTableWizard TableDestination:="Sheet1!R1C3"

********* Problem starts here *************

Run-time error ‘1004-:
Unable to get the PivotTables property of the worksheet class

ActiveSheet.PivotTables("PivotTable2").AddFields RowFields:="dosmoyr", _

ColumnFields:="transmoyr", PageFields:="facilityid"
ActiveSheet.PivotTables("PivotTable2").PivotFields ("Revenue").Orientatio
n =
_
xlHidden
With ActiveSheet.PivotTables("PivotTable2").PivotFields ("Sum of
Payments")
..Orientation = xlDataField
..Caption = " Payments"
..NumberFormat = "#,##0.00_);(#,##0.00)"
End With
ActiveSheet.PivotTables("PivotTable2").DataPivotFi eld.PivotItems("
Payments"). _
Position = 1


C. Pete Straman

--
Message posted via http://www.officekb.com

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
Excel should let me create pivot tables of non-numeric data. Geek4Life Excel Discussion (Misc queries) 4 April 25th 17 11:07 PM
excel 2007 macro recorded pivot table getting old Excel Worksheet Functions 2 April 19th 10 09:06 AM
How do I create unique pivot tables from the same data PEGWINN Excel Discussion (Misc queries) 1 April 9th 10 10:26 PM
Problem with a recorded macro to create two pivot tables from same data Pete Straman via OfficeKB.com[_2_] Excel Programming 1 April 20th 05 05:28 PM
problem with macro for pivot tables Hans Excel Programming 0 July 8th 04 01:50 PM


All times are GMT +1. The time now is 05:23 AM.

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"