Excel Crashes after runnning Macro

kakarot

New Member
Joined
Feb 14, 2011
Messages
12
Hello,

I have created a big macro for formatting a sheet.
Erlier it worked fine with no issues.

Now when I am running it after 2 months, its not working. Every time i run macro, it crashes the excel and start recovering my workbook.

When I run the same macro in Step-in mode (Pressing F8) it works fine with no issues.

I am not able to figure out the prolem with this.

Any suggestions?
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
Can you please post the macro?

ActiveSheet.Select
Range("C1").Cut
Range("B3").Select
ActiveSheet.Paste
'ActiveSheet.Paste Destination:=Range("B3")
Range("C2").Cut
Range("B5").Select
ActiveSheet.Paste
'ActiveSheet.Paste Destination:=Range("B5")
Range("E1").Cut
Range("B7").Select
ActiveSheet.Paste
Application.CutCopyMode = False
'ActiveSheet.Paste Destination:=Range("B7")

'Range("B6").Select
Range("B6").Value = "=""Current Period: ""&RIGHT(R[-3]C[1],6)&"" Currency: ""&RIGHT(RC[-1],3)"
Range("B6").Copy
Range("B6").PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False

till

Range("B6").Copy

every thing is fine. as soon as excel paste the values it carshes. I tried putting a break at 'Application.CutCopyMode = False'.
when execution stops at break point I intentionally stop execution and after this excel crashes. I find out this point after lots of debugging.
 
Upvote 0
Try replacing your code with this:

Code:
Range("C1").Cut Destination:=Range("B3")
Range("C2").Cut Destination:=Range("B5")
Range("E1").Cut Destination:=Range("B7")
Range("B6").Formula = "=""Current Period: ""&RIGHT(R[-3]C[1],6)&"" Currency: ""&RIGHT(RC[-1],3)"
Range("B6").Copy
Range("B6").PasteSpecial Paste:=xlPasteValues
 
Upvote 0
Try replacing your code with this:

Code:
Range("C1").Cut Destination:=Range("B3")
Range("C2").Cut Destination:=Range("B5")
Range("E1").Cut Destination:=Range("B7")
Range("B6").Formula = "=""Current Period: ""&RIGHT(R[-3]C[1],6)&"" Currency: ""&RIGHT(RC[-1],3)"
Range("B6").Copy
Range("B6").PasteSpecial Paste:=xlPasteValues


Earlier code was like this. and problem was started from "Range("C1").Cut Destination:=Range("B3") " so I modified it as above pasted in my post.

Now problem is with
Range("B6").PasteSpecial Paste:=xlPasteValues
 
Upvote 0
It runs fine on my end. Do you have any other code in your workbook that could be running (Worksheet_Change or any other types of events?)
 
Upvote 0
It runs fine on my end. Do you have any other code in your workbook that could be running (Worksheet_Change or any other types of events?)

no there is nothing in thisworkbook module.

the whole code is

Code:
Sub GetOracle(OracleFileName, NewReportTab)
MacroWorkbook_name = ThisWorkbook.Name
MacroWorksheet_Name = ThisWorkbook.ActiveSheet.Name
Application.ScreenUpdating = False
Set PC1 = ThisWorkbook.Worksheets("settings").Range("_PC1")
Set Task1 = ThisWorkbook.Worksheets("settings").Range("Task1")
Set PC2 = ThisWorkbook.Worksheets("settings").Range("_PC2")
Set Task2 = ThisWorkbook.Worksheets("settings").Range("Task2")
Set PC3 = ThisWorkbook.Worksheets("settings").Range("_PC3")
Set Task3 = ThisWorkbook.Worksheets("settings").Range("Task3")
OldReportTab = ActiveSheet.Name
'check if this is a valid report
Select Case ActiveSheet.Name 'find the report title
Case "IS"
FindThis = "IS"
Case "BS"
FindThis = "BS"
End Select
'find the report titles
Workbooks(OracleFileName).Worksheets(NewReportTab).Activate
Set FoundIt = Workbooks(OracleFileName).Worksheets(NewReportTab).Cells.Find(What:=FindThis, After:=ActiveCell, LookIn:= _
xlValues, LookAt:=xlPart, SearchOrder:=xlByColumns, SearchDirection:= _
xlNext, MatchCase:=True, SearchFormat:=False)
'Set FoundIt = Cells.Find(What:=FindThis, After:=ActiveCell, LookIn:= _
xlValues, LookAt:=xlPart, SearchOrder:=xlByColumns, SearchDirection:= _
xlNext, MatchCase:=True, SearchFormat:=False)
If FoundIt Is Nothing Then
Response = MsgBox("The selected report is not a valid " & FindThis & " report." & Chr(10) & Chr(10) _
& "Please make sure you select the right report.", vbCritical, Title)
Application.ScreenUpdating = True
Exit Sub
Else
End If
'check if the sum of the company columns are the same as the total column
Application.ScreenUpdating = False
End_Row = ActiveSheet.Range("A1048576").End(xlUp).Row 'find the last row
Workbooks(OracleFileName).Worksheets(NewReportTab).Cells.Find(What:="CheckSum", After:=ActiveCell, LookIn:=xlValues, _
SearchOrder:=xlByColumns, SearchDirection:=xlNext, _
MatchCase:=True, SearchFormat:=False).Activate
'Cells.Find(What:="CheckSum", After:=ActiveCell, LookIn:=xlValues, _
SearchOrder:=xlByColumns, SearchDirection:=xlNext, _
MatchCase:=True, SearchFormat:=False).Activate
 
ColumnTitle = ActiveCell.Column
SumColumn = Round(Cells(End_Row, ColumnTitle).Offset(0, 1).Value, 2) 'this is the column that has the parent rollup entity
SumOfColumns = Round(Cells(End_Row, ColumnTitle).Value, 2) 'this is the sum column, it will later be deleted if there is no problem
If SumColumn <> SumOfColumns Then
Response = MsgBox("The sum of the columns does not match the Total column." & Chr(10) & Chr(10) _
& "Please check that all the companies included in the Total column are shown on this report." & Chr(10) & Chr(10) _
& "You will need to contact the Data Monkey...", vbCritical, Title)
Application.ScreenUpdating = True
Exit Sub
Else
End If
Load DoublePBar
With DoublePBar
.ProgressDescription1 = "Copying Oracle report to this file..."
.Progress1.Width = 0.4
.Progress2.Width = 0
.Progress3.Width = 0
.Show False
.Height = 160
End With
DoEvents
 
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Workbooks(OracleFileName).Worksheets(NewReportTab).Copy Before:=ThisWorkbook.Sheets(1) 'copy the new report over to this workbook
ThisWorkbook.Sheets(OldReportTab).Delete 'delete the old sheet
Application.DisplayAlerts = True
 
ActiveSheet.Name = OldReportTab 'name the sheet
 
 
'add code fix
'move report title, date, currency and sob
'ActiveSheet.Select
'First Break
'ThisWorkbook.ActiveSheet.Range("C1").Cut
Workbooks(MacroWorkbook_name).Worksheets(MacroWorksheet_Name).Range("C1").Cut
ThisWorkbook.ActiveSheet.Paste Destination:=ThisWorkbook.ActiveSheet.Range("B3")
'ActiveSheet.Range("B3").Select
'ActiveSheet.Paste
'Application.CutCopyMode = False
 
ThisWorkbook.ActiveSheet.Range("C2").Cut
'ActiveSheet.Range("C2").Cut
ThisWorkbook.ActiveSheet.Paste Destination:=ThisWorkbook.ActiveSheet.Range("B5")
 
'Avinash
ThisWorkbook.ActiveSheet.Range("E1").Cut
ThisWorkbook.ActiveSheet.Paste Destination:=ThisWorkbook.ActiveSheet.Range("B7")
 
ThisWorkbook.ActiveSheet.Range("B6").FormulaR1C1 = _
"=""Current Period: ""&RIGHT(R[-3]C[1],6)&"" Currency: ""&RIGHT(RC[-1],3)"
'ActiveCell.FormulaR1C1 = _
"=""Current Period: ""&RIGHT(R[-3]C[1],6)&"" Currency: ""&RIGHT(RC[-1],3)"
ThisWorkbook.ActiveSheet.Range("B6").Copy
'ActiveSheet.Selection.Copy
ThisWorkbook.ActiveSheet.Range("B6").PasteSpecial Paste:=xlPasteValues
'ActiveSheet.Selection.PasteSpecial Paste:=xlPasteValues
ThisWorkbook.ActiveSheet.Range("A6,C1:E3").Clear
'ActiveSheet.Selection.ClearContents
ThisWorkbook.ActiveSheet.Cells.Interior.ColorIndex = xlNone
'ThisWorkbook.Worksheets(OldReportTab).Cells.Interior.ColorIndex = xlNone
' Workbooks(OracleFileName).Worksheets(NewReportTab).Cells.Interior.ColorIndex = xlNone
'ActiveSheet.Cells.Select
'ActiveSheet.Selection.Interior.ColorIndex = xlNone
 
Add_Grouping 'start the colunn and row formating
Range("A2").Select
CloseFile = MsgBox("Do you want to Close " & OracleFileName & "?", vbYesNo, "E*TRADE FINANCIALS")
If CloseFile = vbYes Then
Workbooks(OracleFileName).Close SaveChanges:=False
Else: End If
'clean up and finish
PC1.Value = 0.0001
Task1.Value = "File: "
PC2.Value = 0.0001
Task2.Value = "Columns: "
PC3.Value = 0.0001
Task3.Value = "Rows: "
Unload DoublePBar
ActiveSheet.Calculate
Application.ScreenUpdating = True
Application.StatusBar = False
Unload frmPBar
 
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,587
Messages
6,179,733
Members
452,939
Latest member
WCrawford

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