Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Pivot table marco problem!


Hi

I've recorded a macro that creates a pivot table from a large sum of
data and then creates a chart. However everytime the button that
enables the macro is pushed i get a run time error (although the table
and chart are created perfectly well!)

the code is

Sub Pivot01()
'
' Pivot01 Macro
' Macro recorded 26/09/2005 by bbnr843
'

'
Range("C8").Select
Application.CutCopyMode = False
ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatab ase, SourceData:=
_
"Sheet1!R8C3:R2145C21").CreatePivotTable TableDestination:="",
TableName:= _
"PivotTable1", DefaultVersion:=xlPivotTableVersion10
ActiveSheet.PivotTableWizard TableDestination:=ActiveSheet.Cells(3,
1)
ActiveSheet.Cells(3, 1).Select
With
ActiveSheet.PivotTables("PivotTable1").PivotFields ("YearMonth")
..Orientation = xlRowField
..Position = 1
End With
With
ActiveSheet.PivotTables("PivotTable1").PivotFields ("WPBH_BH_PRTYSTATUS")
..Orientation = xlColumnField
..Position = 1
End With
ActiveSheet.PivotTables("PivotTable1").AddDataFiel d
ActiveSheet.PivotTables( _
"PivotTable1").PivotFields("Count"), "Sum of Count", xlSum
Charts.Add
ActiveChart.SetSourceData Source:=Sheets("Sheet4").Range("A3")
ActiveChart.Location Whe=xlLocationAsNewSheet
ActiveChart.PlotArea.Select
ActiveChart.HasDataTable = True
ActiveChart.DataTable.ShowLegendKey = True
End Sub

The red line is the one that gets flagged by the debug. I think its to
do with the range A3 but i'm not sure what to or how to change it! Any
help with this would be great.

Kind Regards

Matt


--
matthewwookie
------------------------------------------------------------------------
matthewwookie's Profile: http://www.excelforum.com/member.php...o&userid=27503
View this thread: http://www.excelforum.com/showthread...hreadid=470684

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
Problem inserting calculated pivot fields into Pivot Table (2007) wamiller36 Excel Discussion (Misc queries) 1 March 5th 10 11:40 PM
CHANGE MARCO PROBLEM Wu Excel Discussion (Misc queries) 1 November 16th 08 02:34 PM
Pivot Table in Excel 2007 : Problem with % in Table spudsnruf Excel Discussion (Misc queries) 2 January 9th 08 09:53 PM
marco after selection in PV table Dennis Cheung[_2_] Excel Programming 9 May 12th 05 03:45 PM
Marco: Pivot Table Tim Excel Programming 2 April 21st 05 04:53 AM


All times are GMT +1. The time now is 12:57 PM.

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

About Us

"It's about Microsoft Excel"