Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Simple code crashes Excel

I have a workbook that's a template file. The code below works fine
when the file is opened as the (original) template, but when it's
opened as file (template copy) it crashes excel.

This code is contained in a worksheet's on Combo Change event:

Private Sub cboBuildReport_Change()
Application.ScreenUpdating = False
Application.DisplayAlerts = False
On Error Resume Next
Select Case Sheet9.cboBuildReport.Value
Case "Complete"
Sheet1.Delete
Sheet2.Delete
Sheet3.Delete
Sheet4.Delete
Sheet5.Delete
Sheet6.Delete
Sheet7.Delete
Sheet8.Delete
Sheet9.Delete
'Sheet10.Delete
'Sheet11.Delete
Sheet12.Delete
Case "Actual"
'Sheet1.Delete
'Sheet2.Delete
Sheet3.Delete
Sheet4.Delete
Sheet5.Delete
Sheet6.Delete
Sheet7.Delete
Sheet8.Delete
Sheet9.Delete
Sheet10.Delete
Sheet11.Delete
Sheet12.Delete
End Select
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub

Any ideas? I'm thinking it has something to do with the file being a
template, but I'm not sure how this affects the code...
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 36
Default Simple code crashes Excel

John,

I am not an engineer, nor do I play one on TV, but I suspect the problem is
you are deleting the "case criteria" by blowing away Sheet9 before the macro
is completed. The fact that file is an unsaved template (no path??) or a
saved xls or original xlt (has a path) might also have play on this.

Good luck!
Dale

"John" wrote:

I have a workbook that's a template file. The code below works fine
when the file is opened as the (original) template, but when it's
opened as file (template copy) it crashes excel.

This code is contained in a worksheet's on Combo Change event:

Private Sub cboBuildReport_Change()
Application.ScreenUpdating = False
Application.DisplayAlerts = False
On Error Resume Next
Select Case Sheet9.cboBuildReport.Value
Case "Complete"
Sheet1.Delete
Sheet2.Delete
Sheet3.Delete
Sheet4.Delete
Sheet5.Delete
Sheet6.Delete
Sheet7.Delete
Sheet8.Delete
Sheet9.Delete
'Sheet10.Delete
'Sheet11.Delete
Sheet12.Delete
Case "Actual"
'Sheet1.Delete
'Sheet2.Delete
Sheet3.Delete
Sheet4.Delete
Sheet5.Delete
Sheet6.Delete
Sheet7.Delete
Sheet8.Delete
Sheet9.Delete
Sheet10.Delete
Sheet11.Delete
Sheet12.Delete
End Select
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub

Any ideas? I'm thinking it has something to do with the file being a
template, but I'm not sure how this affects the code...

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Code crashes after clearing comments L. Howard Kittle Excel Worksheet Functions 2 February 20th 06 04:54 AM
VBA File in EXCEL 2000 Crashes in code that I have made no changes Jim Excel Programming 2 August 31st 04 08:16 PM
Code crashes when ComboB = empty Stift[_45_] Excel Programming 1 June 30th 04 08:15 AM
Help... This code consistently crashes for no reason. Yo Excel Programming 3 February 5th 04 09:13 AM
Code in ThisWorkbook crashes Excel Pat Beck Excel Programming 6 August 25th 03 09:07 AM


All times are GMT +1. The time now is 05:06 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"