?
Solved

Forcing Excel to delete worksheet using VBA

Posted on 2003-02-21
8
Medium Priority
?
556 Views
Last Modified: 2007-12-19
Hi,

Currently I'm using the following codes to delete a worksheet in excel.

  Sheets("Sheet1").Select
  ActiveWindow.SelectedSheets.Delete

When i execute the macro, it prompts a dialog box asking for confirmation. How can I prevent the dialog box from appearing? Can I force Excel to delete worksheet using VBA?

TQ!
0
Comment
Question by:JavaBlur
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 44

Accepted Solution

by:
bruintje earned 80 total points
ID: 7993209
Hello JavaBlur,

you could try

application.displayalerts =false
Sheets("Sheet1").Select
ActiveWindow.SelectedSheets.Delete
application.displayalerts =true

HAGD:O)Bruintje
0
 
LVL 4

Expert Comment

by:Zmey2
ID: 7993211
Sub del()
Application.DisplayAlerts = False
    Sheets(1).Delete
Application.DisplayAlerts = True
End Sub
0
 
LVL 5

Expert Comment

by:bullethead
ID: 7993218
Use:

Application.DisplayAlerts = False
Sheets("Sheet1").Delete
Application.DisplayAlerts = True

To remove the sheet without a warning.
0
NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

 
LVL 4

Expert Comment

by:Zmey2
ID: 7993225
...quick or dead :)
0
 
LVL 5

Expert Comment

by:bullethead
ID: 7993228
Once again, failed to refresh before posting!

Must learn to type quicker - time to get out Mavis Beacon again!
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 7993236
LOL :-)  There are always 20 different ways of doing anything....

Steve
0
 
LVL 4

Expert Comment

by:Zmey2
ID: 7993262
What a fight for 20 point question!
0
 

Author Comment

by:JavaBlur
ID: 7997369
Thanks everyone for the prompt reply. I managed to find the answer over some website too.
0

Featured Post

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I was prompted to write this article after the recent World-Wide Ransomware outbreak. For years now, System Administrators around the world have used the excuse of "Waiting a Bit" before applying Security Patch Updates. This type of reasoning to me …
Outlook for dependable use in a very small business   This article is about using the Outlook application (part of Microsoft Office) in a very small business, or for homeowners where dependability and reliability are critical requirements. This …
The viewer will learn how to simulate a series of coin tosses with the rand() function and learn how to make these “tosses” depend on a predetermined probability. Flipping Coins in Excel: Enter =RAND() into cell A2: Recalculate the random variable…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question