Hi,
Our company recently transitioned to Office 2007 and one of my macros crashes Excel 2007 - gives "Excel encountered a serious error and needs to close" always at the same spot of the code. I combed the web to see if there are grave differences between VBA in 2003 and 2007 and found nothing...this is the code. I would appreciate any suggestions!
Our company recently transitioned to Office 2007 and one of my macros crashes Excel 2007 - gives "Excel encountered a serious error and needs to close" always at the same spot of the code. I combed the web to see if there are grave differences between VBA in 2003 and 2007 and found nothing...this is the code. I would appreciate any suggestions!
Code:
'Application.Run "INTRANET.XLSM!Revenue_Format" Sub Revenue_Format() areaCount = ActiveCell.CurrentRegion.Rows.Count If areaCount < 1 Then GoTo End_Format: Else GoTo Over_65000: End If Over_65000: areaCount = ActiveCell.CurrentRegion.Rows.Count If areaCount > 65500 Then GoTo End_Format: Else GoTo Continue_Format: End If Continue_Format: Range("H1").Select ActiveCell.FormulaR1C1 = "Parent Principal" Range("A1:L1").Select With Selection.Borders(xlEdgeBottom) .LineStyle = xlContinuous .Weight = xlThin .ColorIndex = xlAutomatic End With With Selection .HorizontalAlignment = xlCenter .VerticalAlignment = xlBottom .WrapText = False .Orientation = 0 .ShrinkToFit = False .MergeCells = False End With Selection.Font.Bold = True Columns("I:I").Select Selection.NumberFormat = "_(* #,##0_);_(* (#,##0);_(* ""-""_);_(@_)" Columns("A:A").Select Selection.NumberFormat = "mmm-yy" Cells.Select Cells.EntireColumn.AutoFit Range("A1").Select ActiveSheet.PivotTableWizard SourceType:=xlDatabase, SourceData:= _ ActiveCell.CurrentRegion, TableDestination:="", TableName:= _ "PivotTable1" ActiveSheet.PivotTables("PivotTable1").AddFields RowFields:="Parent Principal", _ ColumnFields:="Period", PageFields:=Array("Region", "Market", "P&L", _ "Branch Name", "Account", "Principal", "Customer Name", "Division", "Category") With ActiveSheet.PivotTables("PivotTable1").PivotFields("Amount") .Orientation = xlDataField .NumberFormat = "_(* #,##0_);_(* (#,##0);_(* ""-""_);_(@_)" End With Range("A10").Select ActiveSheet.PivotTables("PivotTable1").PivotFields("Data").PivotItems( _ "Sum of Amount").Name = "Revenue Report" Range("C1").Select Selection.EntireRow.Insert Range("A1").Select Application.Run "INTRANET.XLSM!Delete_Data" ActiveWorkbook.Save ActiveWindow.Close End_Format: End Sub
Comment