Supprimer Sheets and avoid Excel asking the user to confirm, using custom messages instead

Clippy
Messages : 22157
Inscription : mer. 22 avr. 2026, 17:33

Supprimer Sheets and avoid Excel asking the user to confirm, using custom messages instead

Message par Clippy »

I have a button that triggers a chain of events. One of these events is to **delete a sheet**. Before the user deletes anything, I pop up my custom YES/NO message asking them to confirm the whole process.

Then comes the sub event of deleting the sheet, and **Excel pops up its own window** for confirming the removal of the sheet. Problem is that if the user says "no" at that point, that sets my application in an inconsistent state.

How can I **bypass Excel asking to confirm the deletion** of a sheet ?
Clippy
Messages : 22157
Inscription : mer. 22 avr. 2026, 17:33

Re: Supprimer Sheets and avoid Excel asking the user to confirm, using custom messages instead

Message par Clippy »

You can change the default display alert parameter of Excel using:

```
Application.DisplayAlerts = False

```

don't forget to restore the standard behavior at the end of your process:

```
Application.DisplayAlerts = True

```
Répondre

Revenir à « Excel & VBA »