Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel Keeps crashing on worksheet delete

Status
Not open for further replies.

FJAY

Programmer
Apr 23, 2003
106
0
0
CA
Excel seems to crash when I try to delete worksheets. The procedure seems to be working in previous release of my tool.
Public Sub delete_worksheet()

Dim shtDelWorkSheet, mySheets

mySheets = Array("A", "B", "C" "D", "E")

For Each shtDelWorkSheet In mySheets
Sheets(shtDelWorkSheet).Visible = False
Application.DisplayAlerts = False
Sheets(shtDelWorkSheet).Delete
Application.DisplayAlerts = True
Next
End Sub

Please what can I do to prevent excel from crashing and giving me the send error report. I've downloaded and installed the latest service pack. Thanks.
 
mySheets = Array("A", "B", "C" "D", "E")

should be
mySheets = Array("A", "B", "C", "D", "E")

You're missing a comma after the "C"

Aside from that, is there an error? Can you step through the code? What line causes it to crash?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top