Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / New Users / January 2008

Tip: Looking for answers? Try searching our database.

Bypass Error message running during macro

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
JMac - 28 Jan 2008 17:21 GMT
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
Dave Peterson - 28 Jan 2008 17:31 GMT
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

> 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.
[quoted text clipped - 15 lines]
> If Sheets(i).Range("A12").Value = "" Then Sheets(i).Delete
> Next i

Signature

Dave Peterson

JMac - 28 Jan 2008 18:08 GMT
> For i = 4 To Sheets.Count
>   If Sheets(i).Range("A12").Value = "" Then
[quoted text clipped - 29 lines]
>
> - Show quoted text -

Thanks! this helps alot!
Bob Phillips - 28 Jan 2008 17:33 GMT
Application.DisplayAlerts = False
   'your delete code
   Application.DisplayAlerts = True

Signature

---
HTH

Bob

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

>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.
[quoted text clipped - 15 lines]
> If Sheets(i).Range("A12").Value = "" Then Sheets(i).Delete
> Next i
Pete_UK - 28 Jan 2008 17:38 GMT
This will stop the messages:

   Application.DisplayAlerts = False

Set it to True to turn them back on again.

Hope this helps.

Pete

> 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.
[quoted text clipped - 15 lines]
> If Sheets(i).Range("A12").Value = "" Then Sheets(i).Delete
> Next i
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.