I'm using the macro below to fill in some cells, then create a Pivot Table in a new worksheet. The macro works fine if I hit F8 (Step Into...) repeatedly in VB, but when I try simply press the "Run" button, it freezes up at Range("H2:H60000").Select. Any thoughts on why this is happening?
Sub ActualsTest2001()
'
' ActualsTest2001 Macro
'
'
Application.CutCopyMode = False
Selection.AutoFill Destination:=Range("H2:H60000"), Type:=xlFillDefault
Range("H2:H60000").Select
Sheets.Add.Name = "Pivot"
Sheets("cji3").Select
Range("A1").Select
ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
"cji3!R1C1:R60000C21", Version:=xlPivotTableVersion12).CreatePivotTable _
TableDestination:="Pivot!R3C1", TableName:="PivotTable1", DefaultVersion _
:=xlPivotTableVersion12
Sheets("Pivot").Select
Cells(3, 1).Select
With ActiveSheet.PivotTables("PivotTable1").PivotFields("year")
.Orientation = xlRowField
.Position = 1
End With
With ActiveSheet.PivotTables("PivotTable1").PivotFields("clin")
.Orientation = xlRowField
.Position = 2
End With
With ActiveSheet.PivotTables("PivotTable1").PivotFields("Cost element name")
.Orientation = xlRowField
.Position = 3
End With
With ActiveSheet.PivotTables("PivotTable1").PivotFields("Resource Code")
.Orientation = xlColumnField
.Position = 1
End With
ActiveSheet.PivotTables("PivotTable1").AddDataField ActiveSheet.PivotTables( _
"PivotTable1").PivotFields("Total Quantity"), "Count of Total Quantity", _
xlCount
ActiveSheet.PivotTables("PivotTable1").AddDataField ActiveSheet.PivotTables( _
"PivotTable1").PivotFields("Value COCurr"), "Count of Value COCurr", xlCount
Range("B5").Select
With ActiveSheet.PivotTables("PivotTable1").PivotFields( _
"Count of Total Quantity")
.Caption = "Hours"
.Function = xlSum
.NumberFormat = "#,##0.0_);[Red](#,##0.0)"
End With
Range("C5").Select
With ActiveSheet.PivotTables("PivotTable1").PivotFields("Count of Value COCurr" _
)
.Caption = "Dollars"
.Function = xlSum
.NumberFormat = "$#,##0.00_);[Red]($#,##0.00)"
End With
End Sub