Excel macro to set Default on Alert to Cancel

TrojanFan

New Member
Joined
Jun 20, 2011
Messages
1
Hello board,
Help! I have a macro that refreshes pivot fields based on user drop down selections. This feature works great, however, if a user selects drop down combinations that do not have data sets, the macro prompts an excel alert "Do you want to replace cell contents" because the pivot expands into neighboring cells with formulas.

I want this alert to be handled within the macro, invisible to the user, where the macro automatically selects Cancel.
Upon hitting cancel, I have the code running an OnError script. My issue is having the alert set to cancel! Can this be done?

I've seen many postings for the code below which disables the alerts but the default setting is to "OK". I need it to answer "Cancel".

Application.DisplayAlerts = False
Application.DisplayAlerts = True

Any input is appreciated.
-TrojanFan
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.

Forum statistics

Threads
1,224,584
Messages
6,179,693
Members
452,938
Latest member
babeneker

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