Thank you for being a valued part of the CNET community. As of December 1, 2020, the forums are in read-only format. In early 2021, CNET Forums will no longer be available. We are grateful for the participation and advice you have provided to one another over the years.

Thanks,

CNET Support

General discussion

Macro to include confirmation in Excel

Apr 22, 2007 7:00PM PDT

I'm trying to produce a macro that will delete a worksheet. the actual deletion is not a problem but I don't want the box to come up asking if I'm sure - I just want it to do the deletion.

Is there code for a macro that will automatically accept "OK"?

Thanks for any help

Dave Cooper

Discussion is locked

- Collapse -
Doesn't Kill do this?
Apr 22, 2007 7:06PM PDT
- Collapse -
Arg. Killing just a sheet of the ss, not the entire ss?
Apr 22, 2007 8:46PM PDT

I mussed up.

Bob

- Collapse -
Yes, there is.
Apr 22, 2007 8:31PM PDT

But I'll have to look it up at home in an application I wrote. I don't know by head.

Kill, of course, is for files (workbooks), not for individual sheets in a workbook.

Kees

- Collapse -
Use the Application.DisplayAlerts command
Apr 23, 2007 1:20AM PDT

If you just want to delete a worksheet and not a full workbook, then in your VBA code use the following lines:

Application.ScreenUpdating = False 'This stops the screen from flickering. Useful if the code activates other sheets
Application.DisplayAlerts = False 'This stops all warning messages.

Be sure to reverse the commands to True before you exit or end sub.


Mark

- Collapse -
Thanks
Apr 23, 2007 2:29AM PDT

Thanks to all!