Run-time error 1004: Method 'Axes' of object '_chart' failed

G

Guest

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:=xlDatabase, 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").DataPivotField.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,23: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 Where:=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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top