Delete button using Macro

dukeofscouts

Board Regular
Joined
Jan 19, 2009
Messages
146
Sounds simple enough, but here is the issue:
I'm using a Macro to create a "Are you sure" button. Click the second button a macro runs that saves the results into a database, and clears the date that the results are based off of. I'd like to then delete the "Are you sure" button, so that I can't accidenetly clear the data before I'm ready to. The VBA code defines the button by the name (Ie: Button 4). However, since the button is made fresh each time, the name is not the same every time causing an error message to appear when I run the macro. The button is in the same place on the worksheet everytime the creation macro runs. Is there a way around this error that will allow me to delete the button?

Time line:
-Enter Data
-Click "Save and Clear" Button
--Display "Are you Sure" Button
-Click "Are you Sure" Button
--Save results of data entry, clear Data, and delete "are you sure" Button
(Repeat)
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
Rather than a permenant button, how about a message box, like
Code:
If MsgBox("Are you sure you want to delete?", vbYesNo)=vbNo Then Exit Sub
 
Upvote 0

Forum statistics

Threads
1,215,047
Messages
6,122,858
Members
449,096
Latest member
Erald

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