View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Adrian Adrian is offline
external usenet poster
 
Posts: 57
Default Run-time Error 1004: Application-defined or Object-defined Error

Hi, Can anyone help me. I get this message when using the Macro's and I'm not
sure how to fix... Below is a snippet of code - The error occurs on the last
three lines of code... Any suggestions?

Thanks

Sheets.Add
Sheets.Add
Sheets("Sheet1").Select
ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatab ase, SourceData:= _
"Sheet1!R1C1:R25000C37").CreatePivotTable TableDestination:="",
TableName:= _
"PivotTable1", DefaultVersion:=xlPivotTableVersion10
ActiveSheet.PivotTableWizard TableDestination:=ActiveSheet.Cells(3, 1)
ActiveSheet.Cells(3, 1).Select
ActiveSheet.PivotTables("PivotTable1").AddFields RowFields:= _
"StatusDescription"
ActiveSheet.PivotTables("PivotTable1").PivotFields ("StatusDescription"). _
Orientation = xlDataField
With
ActiveSheet.PivotTables("PivotTable1").PivotFields ("StatusDescription")
.PivotItems("(blank)").Visible = False
End With
Sheets("Sheet1").Select

ActiveWorkbook.Worksheets("Sheet4").PivotTables("P ivotTable1").PivotCache. _
CreatePivotTable TableDestination:="", TableName:="PivotTable2", _
DefaultVersion:=xlPivotTableVersion10