Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Run-time error 1004: Method 'Axes' of object '_chart' failed

Can you pleaese tell me how to fixthe error in the following code:

Sub Macro1()
'
' Macro1 Macro
' Macro recorded 10/19/2005 by bamorris
'

'
ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatab ase, SourceData:= _
"Data!R1C1:R9999C42").CreatePivotTable TableDestination:="",
TableName:= _
"PivotTable1", DefaultVersion:=xlPivotTableVersion10
ActiveSheet.PivotTableWizard TableDestination:=ActiveSheet.Cells(3, 1)
ActiveSheet.Cells(3, 1).Select
ActiveSheet.PivotTables("PivotTable1").AddFields RowFields:="item_desc"
With
ActiveSheet.PivotTables("PivotTable1").PivotFields ("transaction_cost")
.Orientation = xlDataField
.Caption = "Sum of transaction_cost"
.Function = xlSum
End With
Range("B5").Select
Selection.Sort Key1:="R5C2", Order1:=xlDescending, Type:=xlSortValues, _
OrderCustom:=1, Orientation:=xlTopToBottom
Range("A4").Select
ActiveSheet.PivotTables("PivotTable1").AddFields
RowFields:=Array("item_desc" _
, "Data")
With ActiveSheet.PivotTables("PivotTable1").PivotFields ("quantity")
.Orientation = xlDataField
.Caption = "Sum of quantity"
.Function = xlSum
End With
ActiveSheet.PivotTables("PivotTable1").DataPivotFi eld.PivotItems( _
"Sum of quantity").Position = 2
Range("A4:D33").Select
Range("D4").Activate
Selection.Copy
Range("E4").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Columns("A:D").Select
Range("D1").Activate
Application.CutCopyMode = False
Selection.Delete Shift:=xlToLeft
Range("C5").Select
Selection.Cut Destination:=Range("D4")
Range("C7").Select
Selection.Cut Destination:=Range("D6")
Range("C9").Select
Selection.Cut Destination:=Range("D8")
Range("C11").Select
Selection.Cut Destination:=Range("D10")
Range("C13").Select
Selection.Cut Destination:=Range("D12")
Range("C15").Select
Selection.Cut Destination:=Range("D14")
Range("C17").Select
Selection.Cut Destination:=Range("D16")
Range("C19").Select
Selection.Cut Destination:=Range("D18")
Range("C21").Select
Selection.Cut Destination:=Range("D20")
Range("C23").Select
Selection.Cut Destination:=Range("D22")
Range("C25").Select
Selection.Cut Destination:=Range("D24")
Range("C27").Select
Selection.Cut Destination:=Range("D26")
Range("C29").Select
Selection.Cut Destination:=Range("D28")
Range("C31").Select
Selection.Cut Destination:=Range("D30")
Range("C33").Select
Selection.Cut Destination:=Range("D32")
Range("B4").Select
Selection.Cut Destination:=Range("C3")
Range("B5").Select
Selection.Cut Destination:=Range("D3")
Columns("B:B").Select
Selection.Delete Shift:=xlToLeft
Range( _

"5:5,7:7,9:9,11:11,13:13,15:15,17:17,19:19,21:21,2 3:23,25:25,27:27,29:29,31:31" _
).Select
Range("A31").Activate
Selection.Delete Shift:=xlUp
Cells.Select
Cells.EntireColumn.AutoFit
Range("A3").Select
ActiveCell.FormulaR1C1 = "Description"
Range("A2").Select
Charts.Add
ActiveChart.ApplyCustomType ChartType:=xlBuiltIn, TypeName:= _
"Line - Column on 2 Axes"
ActiveChart.SetSourceData Source:=Sheets("Sheet1").Range("A3:C18"),
PlotBy _
:=xlColumns
ActiveChart.Location Whe=xlLocationAsNewSheet, Name:="Chart"
With ActiveChart
.HasTitle = True
.ChartTitle.Characters.Text = "Top 15 Spares by Total Cost"
.Axes(xlCategory, xlPrimary).HasTitle = False
.Axes(xlValue, xlPrimary).HasTitle = False
.Axes(xlCategory, xlSecondary).HasTitle = False
.Axes(xlValue, xlSecondary).HasTitle = False
End With
End Sub
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
Charts.Add error '1004' Method 'Add' of object 'Sheets' failed Corey Charts and Charting in Excel 1 December 28th 06 02:15 PM
Error 1004 Method 'Add'of Object Sheets failed ExcelMonkey[_190_] Excel Programming 10 March 29th 05 01:52 PM
Runime Error 1004 Method Range of Object Global Failed Mohan[_5_] Excel Programming 3 May 21st 04 03:35 PM
Error 1004: Method 'Cells' of object '_Global' failed LT Excel Programming 2 October 31st 03 04:47 PM
"Run-time error '1004'" Method 'Range' of object '_global' failed. haisat[_2_] Excel Programming 0 October 20th 03 12:13 PM


All times are GMT +1. The time now is 09:03 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"