Hi All:</SPAN>
Our Office was recently upgraded from Excel 2003 to Excel 2010 and I am having an issue with a macro that when run stops Excel from working. When I click the Refresh button it starts running but then I get the following error:</SPAN>
Microsoft Excel has stopped working (my only option is "Close the Program")</SPAN>
If I go into VBA and step through the code it works for me but not when I use the button. I have tons of other codes in the spreadsheet but I have ripped them all out and still get the error. I think the error is when it tries to delete the sheet titles Journal. If I remove the line of code that deletes that sheet and rename the copied sheet to Journal NEW instead of Journal the code works. ?????????????????????</SPAN>
Here are my references in VBA:</SPAN>
References - VBAProject</SPAN>
Visual Basic For Applications</SPAN>
Microsoft Excel 14.0 Object Library</SPAN>
Microsoft Forms 2.0 Object Library</SPAN>
Microsoft HTML Object Library</SPAN>
Microsoft Internet Controls</SPAN>
Microsoft Visual Basics for Applications Extensibility 5.3</SPAN>
OLE Automation</SPAN>
Here is the code that craps out when run using a button:</SPAN>
Our Office was recently upgraded from Excel 2003 to Excel 2010 and I am having an issue with a macro that when run stops Excel from working. When I click the Refresh button it starts running but then I get the following error:</SPAN>
Microsoft Excel has stopped working (my only option is "Close the Program")</SPAN>
If I go into VBA and step through the code it works for me but not when I use the button. I have tons of other codes in the spreadsheet but I have ripped them all out and still get the error. I think the error is when it tries to delete the sheet titles Journal. If I remove the line of code that deletes that sheet and rename the copied sheet to Journal NEW instead of Journal the code works. ?????????????????????</SPAN>
Here are my references in VBA:</SPAN>
References - VBAProject</SPAN>
Visual Basic For Applications</SPAN>
Microsoft Excel 14.0 Object Library</SPAN>
Microsoft Forms 2.0 Object Library</SPAN>
Microsoft HTML Object Library</SPAN>
Microsoft Internet Controls</SPAN>
Microsoft Visual Basics for Applications Extensibility 5.3</SPAN>
OLE Automation</SPAN>
Here is the code that craps out when run using a button:</SPAN>
Code:
Sub REFRESH_Journal()
Sheets("Journal").Select
Application.DisplayAlerts = False
[COLOR=#ff0000]ActiveWindow.SelectedSheets.Delete
[/COLOR] Sheets("Journal (BackUp)").Visible = True
Sheets("Journal (BackUp)").Copy Before:=Sheets(9)
Sheets("Journal (BackUp)").Select
Sheets("Journal (BackUp)").Visible = xlVeryHidden
Sheets("Journal (BackUp) (2)").Select
[COLOR=#ff0000] Sheets("Journal (BackUp) (2)").name = "Journal"
[/COLOR]
'Opportunity to SAVE a copy to your HardDrive
Answer = MsgBox("Do you need to UNHIDE the Hidden Rows on the worksheet?" & vbNewLine & vbNewLine & _
"If you do then click YES if not then click No.", vbYesNo, "Reveal Hidden ROws???")
If Answer = vbYes Then
'Remove Filter (Shows all rows again)
Sheets("Deposit Worksheet").Select
ActiveSheet.Unprotect "invoice"
Selection.AutoFilter
Range("C4:D4").Select
ActiveSheet.Protect "invoice"
Sheets("Journal").Select
Range("M2").Select
If Answer = vbNo Then
End If
End If
Application.DisplayAlerts = True
End Sub
Any suggestions?
THANKS,
Mark