Excel Crashes on Save after Macro Runs

Lasharena

New Member
Joined
Apr 17, 2013
Messages
4
Hello All, I am reposting this question as it has been two days without a response.

My macro runs start to finish with no problem, but after it is done running it always crashes Excel (2007) when I try to save the file containing the macro. I get the below error details.

Problem signature:</SPAN>
Problem Event Name: APPCRASH
</SPAN>
Application Name: EXCEL.EXE
</SPAN>
Application Version: 12.0.6665.5003
</SPAN>
Application Timestamp: 5061d2a8
</SPAN>
Fault Module Name: EXCEL.EXE
</SPAN>
Fault Module Version: 12.0.6665.5003
</SPAN>
Fault Module Timestamp: 5061d2a8
</SPAN>
Exception Code: c0000005
</SPAN>
Exception Offset: 004863b3
</SPAN>
OS Version: 6.1.7601.2.1.0.256.48
</SPAN>
Locale ID: 1033
</SPAN>

Additional information about the problem:
</SPAN>
LCID: 1033
</SPAN>
Brand: Office12Crash
</SPAN>
skulcid: 1033

When I step through the entire macro it does let me save. But EVERY time I run all the way through it crashes on the save. Thus I cannot even pinpoint what section of code may be causing this.

I have some basic "for each" loops, userforms, lots of copy and pasting, sorting, and it open files to paste some results in and saves and closes them (with no problem ?!?). But it crashes the file with the macro when it saves (very odd). I tried saving with and without code to do it. I copied the macro text to a new file with the same results, so it is the code. Please let me know if you would like the code to look at, but it is several pages long.

Does anyone know what could cause such a strange error?

Thanks in advance for your help! :)
</SPAN></SPAN>
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
I started copy/pasting sections of code until it crashed on me. This was the section I copied that made Excel crash on saving the file the macro primarily focuses on. This is past a point where other files have been opened, edited, saved, and closed.

Code:
'''''Gets Journal tab ready to accept new Journal lines

Dim PJeRowTop, PJeRowBottom, PJeRowCnt As Integer
Dim PJeRange As Range

Sheets("Journal").Activate
Cells(45000, 4).Select
PJeRowBottom = Selection.End(xlUp).Row
Range(Cells(30, 4), Cells(PJeRowBottom, 4)).Select
Set PJeRange = Selection
PJeRowCnt = Selection.Rows.count

If NonICRowCnt = PJeRowCnt Then
GoTo JECopy
ElseIf NonICRowCnt > PJeRowCnt Then
GoTo AddRows
ElseIf NonICRowCnt < PJeRowCnt Then
GoTo DeleteRows
End If

AddRows:
Dim AddRows As Integer

AddRows = NonICRowCnt - PJeRowCnt
Cells(31, 4).Select
Range(Selection, Selection.Offset(AddRows - 1, 0)).EntireRow.Insert
GoTo JECopy
DeleteRows:
Dim DeleteRows As Integer

DeleteRows = PJeRowCnt - NonICRowCnt
Cells(31, 4).Select
Range(Selection, Selection.Offset(DeleteRows - 1, 0)).EntireRow.Delete
'''''Copies New JE lines to Journal Tab
JECopy:
 
Upvote 0
Has anyone ever had this problem before? I don't understand why the above code would cause the file to crash when it saves.
 
Upvote 0

Forum statistics

Threads
1,223,229
Messages
6,170,881
Members
452,364
Latest member
springate

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