Bypass Error message running during macro

J

JMac

I have a macro that is deleting worksheet pages that do not have data
entry. It can range from 1-23 worksheets that are going to be deleted.
Since I am deleting a workseet, I receive the notice that: "Data may
exist in the sheet(s) selected for deletion. To permanently delete the
sheets, press Delete." Then I press delete, and the macro continues to
the next sheet.
Is there a way to automatically set it to delete without the caution?

TIA,

Josh

My code for going through the workbook is as follows:
The first sheets are necessary to the workbook so they are skipped.
(i=4)

For i = 4 To Sheets.Count
If Sheets(i).Range("A12").Value = "" Then Sheets(i).Delete
Next i
 
D

Dave Peterson

For i = 4 To Sheets.Count
If Sheets(i).Range("A12").Value = "" Then
application.displayalerts = false
Sheets(i).Delete
application.displayalerts = true
end if
Next i
 
B

Bob Phillips

Application.DisplayAlerts = False
'your delete code
Application.DisplayAlerts = True


--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)
 
P

Pete_UK

This will stop the messages:

Application.DisplayAlerts = False

Set it to True to turn them back on again.

Hope this helps.

Pete
 
J

JMac

For i = 4 To Sheets.Count
  If Sheets(i).Range("A12").Value = "" Then
    application.displayalerts = false
    Sheets(i).Delete
    application.displayalerts = true
  end if
Next i







--

Dave Peterson- Hide quoted text -

- Show quoted text -

Thanks! this helps alot!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top