DisplayAlerts

peterbata

New Member
Joined
Feb 20, 2016
Messages
20
Hello and thank you for taking my inquiry.

I am learning about VBA code and am wondering why when stepping through these lines of code I am not presented with a warning prompt. It executes successfully but no warning. The sheet is deleted.

Sub DeleteSpecificSheets()


Application.DisplayAlerts = False
Worksheets("sheet8").Delete
Application.DisplayAlerts = True


End Sub
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
Because the code cycles it off and then back on.

OFF
Code:
Application.DisplayAlerts = False

ON
Code:
Application.DisplayAlerts = True
 
Upvote 0
Thank you so much for the incredibly fast response Jeffrey


My apologies. I was wrong.

The instructor steps through this code when receiving the warning prompt. I do the same and no result.

Sub DeleteSpecificSheets()


Worksheets("sheet7").Delete


End Sub
 
Last edited:
Upvote 0
Hi Peter,

If you do not want to get a warning prompt, then you must do...

Code:
Sub DeleteSpecificSheets()
    Application.DisplayAlerts = False
        Worksheets("Sheet2").Delete
    Application.DisplayAlerts = True
End Sub

I did not watch the youtube link, but not sure it's necessary
 
Upvote 0
If you do not want the warning prompt then you need those two lines.

False at the beginning of the code and True at the end

I'm sorry that we seem to be going around in circles here. I DO want to see the alerts. I was simply inquiring as to why I was NOT seeing the prompt at all.
 
Upvote 0
I was simply inquiring as to why I was NOT seeing the prompt at all.

I simply do not know why you are not seeing the prompt as I don't see your sheet and I don't know what you are actually running, when, or how.

If you want to see the alerts, then you would use...

Code:
Sub DeleteSpecificSheets()
    Worksheets("Sheet2").Delete
End Sub

If you DO NOT want to see the alerts, then you would use...
Code:
Sub DeleteSpecificSheets()
    Application.DisplayAlerts = False
        Worksheets("Sheet2").Delete
    Application.DisplayAlerts = True
End Sub

Maybe it's possible the workbook you are in has the alerts turned off so they need to be reset so the code works as it should.

Open up the VBE (Alt + F11)
Open up the Immediate window (Ctrl + G)
Now in the Immediate window paste >> Application.DisplayAlerts = True >> select enter

Try to run code #1 above and make sure you change the Sheet name to what you are actually working with.
 
Upvote 0
I really appreciate your time and assistance Jeffrey.

I suppose that I should have have provided more info on my environment in my original post. My bad

Using Microsoft Excel 2016 in Windows 7 Pro
I created a new worksheet. Sheets 1,2,3. All empty, absolutely no data.

I proceed to: Open up the VBE (Alt + F11)
Followed by: Open up the Immediate window (Ctrl + G)
I then went into the:
Immediate window paste >> Application.DisplayAlerts = True >> select enter

Then ran the code #1 as you said.

Not sure if you will be able to see this screenshot.

Excel%20VBE%20-%2029-03-2016%2014-55-36%20PM_zpspor6rvbp.jpg


I'm baffled!
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,430
Messages
6,124,849
Members
449,194
Latest member
HellScout

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top