Hi
I have created a macro in Excel 2007 that creates a pivot table but quite often when I run it I get the following message...
Runtime error 1004
Unable to set the ShowDetail property of the Range class..
This is the code...and it's at the very last bit that Excel shows up as the problem..i.e. Selection.ShowDetail = True
I suspect that it's something obvious. I'm using this code to
ActiveWorkbook.PivotCaches.Create(SourceType:=xlConsolidation, SourceData:= _
Array("Prodn_Plan_Prep!R1C1:R2000C18"), Version:=xlPivotTableVersion10). _
CreatePivotTable TableDestination:="", TableName:="PivotTable1", _
DefaultVersion:=xlPivotTableVersion10
ActiveSheet.PivotTableWizard TableDestination:=ActiveSheet.Cells(3, 1)
ActiveSheet.Cells(3, 1).Select
ActiveSheet.PivotTables("PivotTable1").DataPivotField.PivotItems("Sum of Value" _
).Position = 1
Range("B3").Select
ActiveSheet.PivotTables("PivotTable1").PivotFields("Column").Name = "mmm-yy"
Range("S20000").Select
Selection.ShowDetail = True
End Sub
Bookmarks