View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.programming
Gary Brown[_5_] Gary Brown[_5_] is offline
external usenet poster
 
Posts: 236
Default Yet another undesired pop-up

When it can't find the worksheet, it goes to the next line which basically
says DELETE THE CURRENT WORKSHEET.
Use this syntax..
Sheets("q793complete").Delete
That way, if it can't find the sheet, it moves on instead of doing a blind
delete.
HTH,
Gary Brown


"CLR" wrote:

Hmmmm.....I must be doing something wrong......when I did that, after adding
Gary's suggestion, the macro passed over that part of the code where it
looked for the sheets I wanted to delete.........but then for some reason, it
wiped out almost every other sheet in the book.

Vaya con Dios,
Chuck, CABGx3



"Jim Thomlinson" wrote:

at the top of the code add

on error resume next

When the sheet to delete is not found the code will just continue on the
next line...

HTH

"CLR" wrote:

Thanks very much Gary.......That took care of the first part, real fine.....


Vaya con Dios,
Chuck, CABGx3



"Gary Brown" wrote:

CLR,
You need to turn the warnings off.
Try...
Application.DisplayAlerts = False
YOUR CODE HERE
Application.DisplayAlerts = True

HTH,
Gary Brown


"CLR" wrote:

Hi All......

I recorded a macro that works ok, except that with each sheet deletion, I
get a pop-up that stops the macro execution until I manually acknowledge it.
Oh, another annoyance is that if the sheet does not exist, the macro
crashes.......

Could anyone please help with either problem?


Sub ClearProgram()

'Delete the unwanted sheets
Sheets("q793complete").Select
ActiveWindow.SelectedSheets.Delete
Sheets("tblDPM").Select
ActiveWindow.SelectedSheets.Delete
Sheets("PartTrend").Select
ActiveWindow.SelectedSheets.Delete
Sheets("q794Trends").Select
ActiveWindow.SelectedSheets.Delete
Sheets("q261Defects").Select
ActiveWindow.SelectedSheets.Delete
Sheets("q261Parts").Select
ActiveWindow.SelectedSheets.Delete
'Clear the NUMBERBASE range on the DPMcalcs sheet
Sheets("DPMCalcs").Select
ActiveWindow.ScrollColumn = 1
Application.GoTo Reference:="NUMBERBASE"
Selection.ClearContents
Sheets("Main").Select
Range("C8").Select

End Sub

TIA
Vaya con Dios,
Chuck, CABGx3