PC Review


Reply
Thread Tools Rate Thread

Bypass Error message running during macro

 
 
JMac
Guest
Posts: n/a
 
      28th Jan 2008
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
 
Reply With Quote
 
 
 
 
Dave Peterson
Guest
Posts: n/a
 
      28th Jan 2008
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

JMac wrote:
>
> 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
 
Reply With Quote
 
Bob Phillips
Guest
Posts: n/a
 
      28th Jan 2008
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)



"JMac" <(E-Mail Removed)> wrote in message
news:e1876c32-2890-4b72-8f11-(E-Mail Removed)...
>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



 
Reply With Quote
 
Pete_UK
Guest
Posts: n/a
 
      28th Jan 2008
This will stop the messages:

Application.DisplayAlerts = False

Set it to True to turn them back on again.

Hope this helps.

Pete

On Jan 28, 5:21*pm, JMac <mcdow...@gmail.com> wrote:
> 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


 
Reply With Quote
 
JMac
Guest
Posts: n/a
 
      28th Jan 2008
On Jan 28, 11:31*am, Dave Peterson <peter...@verizonXSPAM.net> wrote:
> 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
>
>
>
>
>
> JMac wrote:
>
> > 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- Hide quoted text -
>
> - Show quoted text -


Thanks! this helps alot!
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Send email if an error message popup when running macro Nancy Microsoft Access Macros 0 16th Sep 2008 04:41 PM
Running Macro - output pivot table to excel - error message 2046 =?Utf-8?B?Qm9i?= Microsoft Access VBA Modules 0 13th May 2007 03:56 AM
How do I bypass the message to save when closing a file by macro? =?Utf-8?B?c2ptcGNlY0Bhbm9uLmNvbQ==?= Microsoft Excel Programming 3 21st Aug 2006 09:01 PM
Excel error message when running Macro. =?Utf-8?B?c2J5?= Microsoft Excel Crashes 0 20th Mar 2006 03:06 PM
Error Message when running macro =?Utf-8?B?RGViYmll?= Microsoft Access Getting Started 1 24th Jun 2005 02:37 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:41 PM.