ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Delete Sheet (https://www.excelbanter.com/excel-programming/321795-delete-sheet.html)

Dthmtlgod[_3_]

Delete Sheet
 
I have this code to delete the sheet. Pretty simple. How can I have it
delete the sheet without any user intervention?

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




Chip[_3_]

Delete Sheet
 
When would you like the sheet deleted? It needs to be done on some
action (i.e. when a cell is selected, when the file is opened, etc.)


JE McGimpsey

Delete Sheet
 
One way:

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

In article ,
"Dthmtlgod" wrote:

I have this code to delete the sheet. Pretty simple. How can I have it
delete the sheet without any user intervention?

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


K Dales[_2_]

Delete Sheet
 
The answer to your question depends on when you need the sheet deleted. If
no user intervention, the routine needs some way to know it is time to delete
- so when is that? For example, if you want it to delete when the user
closes the workbook, you would put the code in the Workbook_BeforeClose event
procedure.

On another topic - to simplify the code further:
Sheets("wcexcel").Delete

"Dthmtlgod" wrote:

I have this code to delete the sheet. Pretty simple. How can I have it
delete the sheet without any user intervention?

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





Lonnie M.

Delete Sheet
 
Hi, when you say deleting without user intervention do you mean without
having to respond to a prompt asking you if you want to delete the
sheet or cancel? If so, try this:

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

HTH--Lonnie M.


Lonnie M.

Delete Sheet
 
Yah, like JE McGimpsey said... :)



All times are GMT +1. The time now is 07:20 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com