Macro hanging up on its own, but works with "Step Into..." - Excel07

mustang

New Member
Joined
Dec 27, 2005
Messages
35
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
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).

Forum statistics

Threads
1,214,830
Messages
6,121,835
Members
449,051
Latest member
excelquestion515

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top