Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
COG COG is offline
external usenet poster
 
Posts: 7
Default Macro for Confirming Delete

Hi all, I can create a button with a macro that will
clear the data in a preselected range - using the macro
recorder. However, when the button is clicked, I would
like a message to appear that says, "Are You Sure" and
have a "Yes" button, and a "No" button for the user to
click on - to verify clear the range or return to what
they were doing. I think this is a macro inside a macro
and I am not sure how to do this. Any HELP you can offer
would be appreciated. Ex - when you start to close an
Excel file you've entered data into, and haven't saved
it, a message will appear asking if you really want to
save changes. How can I create such a message with
options yes and no?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Macro for Confirming Delete

try help under msgbox

that should get you in the right direction

"COG" wrote in message
...
Hi all, I can create a button with a macro that will
clear the data in a preselected range - using the macro
recorder. However, when the button is clicked, I would
like a message to appear that says, "Are You Sure" and
have a "Yes" button, and a "No" button for the user to
click on - to verify clear the range or return to what
they were doing. I think this is a macro inside a macro
and I am not sure how to do this. Any HELP you can offer
would be appreciated. Ex - when you start to close an
Excel file you've entered data into, and haven't saved
it, a message will appear asking if you really want to
save changes. How can I create such a message with
options yes and no?



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 618
Default Macro for Confirming Delete

Hi Cog

a message box will do what you're after

e.g.

sub yourexistingcode()

dim i as long

i = msgbox("Are you sure?",vbyesno,"Be very, very sure!")
if i = vbno then
msgbox "No data is to be deleted!",vbOkOnly,"Don't Delete Data"
'this is optional, just put here as an example
exit sub
end if

---your delete code here

end sub


Cheers
JulieD

"COG" wrote in message
...
Hi all, I can create a button with a macro that will
clear the data in a preselected range - using the macro
recorder. However, when the button is clicked, I would
like a message to appear that says, "Are You Sure" and
have a "Yes" button, and a "No" button for the user to
click on - to verify clear the range or return to what
they were doing. I think this is a macro inside a macro
and I am not sure how to do this. Any HELP you can offer
would be appreciated. Ex - when you start to close an
Excel file you've entered data into, and haven't saved
it, a message will appear asking if you really want to
save changes. How can I create such a message with
options yes and no?



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Macro for Confirming Delete

Try something like

If MsgBox("Are you sure?", vbYesNo) = vbNo Then
Exit Sub
End If


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com




"COG" wrote in message
...
Hi all, I can create a button with a macro that will
clear the data in a preselected range - using the macro
recorder. However, when the button is clicked, I would
like a message to appear that says, "Are You Sure" and
have a "Yes" button, and a "No" button for the user to
click on - to verify clear the range or return to what
they were doing. I think this is a macro inside a macro
and I am not sure how to do this. Any HELP you can offer
would be appreciated. Ex - when you start to close an
Excel file you've entered data into, and haven't saved
it, a message will appear asking if you really want to
save changes. How can I create such a message with
options yes and no?



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 618
Default Macro for Confirming Delete

you're welcome
"COG" wrote in message
...
Thank you for your help!
-----Original Message-----
Hi Cog

a message box will do what you're after

e.g.

sub yourexistingcode()

dim i as long

i = msgbox("Are you sure?",vbyesno,"Be very, very

sure!")
if i = vbno then
msgbox "No data is to be

deleted!",vbOkOnly,"Don't Delete Data"
'this is optional, just put here as an example
exit sub
end if

---your delete code here

end sub


Cheers
JulieD

"COG" wrote in

message
...
Hi all, I can create a button with a macro that will
clear the data in a preselected range - using the macro
recorder. However, when the button is clicked, I would
like a message to appear that says, "Are You Sure" and
have a "Yes" button, and a "No" button for the user to
click on - to verify clear the range or return to what
they were doing. I think this is a macro inside a

macro
and I am not sure how to do this. Any HELP you can

offer
would be appreciated. Ex - when you start to close an
Excel file you've entered data into, and haven't saved
it, a message will appear asking if you really want to
save changes. How can I create such a message with
options yes and no?



.





  #6   Report Post  
Posted to microsoft.public.excel.programming
COG COG is offline
external usenet poster
 
Posts: 7
Default Macro for Confirming Delete

Thank you for your help!
-----Original Message-----
Hi Cog

a message box will do what you're after

e.g.

sub yourexistingcode()

dim i as long

i = msgbox("Are you sure?",vbyesno,"Be very, very

sure!")
if i = vbno then
msgbox "No data is to be

deleted!",vbOkOnly,"Don't Delete Data"
'this is optional, just put here as an example
exit sub
end if

---your delete code here

end sub


Cheers
JulieD

"COG" wrote in

message
...
Hi all, I can create a button with a macro that will
clear the data in a preselected range - using the macro
recorder. However, when the button is clicked, I would
like a message to appear that says, "Are You Sure" and
have a "Yes" button, and a "No" button for the user to
click on - to verify clear the range or return to what
they were doing. I think this is a macro inside a

macro
and I am not sure how to do this. Any HELP you can

offer
would be appreciated. Ex - when you start to close an
Excel file you've entered data into, and haven't saved
it, a message will appear asking if you really want to
save changes. How can I create such a message with
options yes and no?



.

  #7   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default Macro for Confirming Delete

Thank you for your help!
-----Original Message-----
Try something like

If MsgBox("Are you sure?", vbYesNo) = vbNo Then
Exit Sub
End If


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com




"COG" wrote in

message
...
Hi all, I can create a button with a macro that will
clear the data in a preselected range - using the macro
recorder. However, when the button is clicked, I would
like a message to appear that says, "Are You Sure" and
have a "Yes" button, and a "No" button for the user to
click on - to verify clear the range or return to what
they were doing. I think this is a macro inside a

macro
and I am not sure how to do this. Any HELP you can

offer
would be appreciated. Ex - when you start to close an
Excel file you've entered data into, and haven't saved
it, a message will appear asking if you really want to
save changes. How can I create such a message with
options yes and no?



.

  #8   Report Post  
Posted to microsoft.public.excel.programming
COG COG is offline
external usenet poster
 
Posts: 7
Default Macro for Confirming Delete

Thanks for your help.
-----Original Message-----
try help under msgbox

that should get you in the right direction

"COG" wrote in

message
...
Hi all, I can create a button with a macro that will
clear the data in a preselected range - using the macro
recorder. However, when the button is clicked, I would
like a message to appear that says, "Are You Sure" and
have a "Yes" button, and a "No" button for the user to
click on - to verify clear the range or return to what
they were doing. I think this is a macro inside a

macro
and I am not sure how to do this. Any HELP you can

offer
would be appreciated. Ex - when you start to close an
Excel file you've entered data into, and haven't saved
it, a message will appear asking if you really want to
save changes. How can I create such a message with
options yes and no?



.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Confirming Vlues in 2 Cells Appear in a List Jamie M Excel Worksheet Functions 2 March 11th 06 02:14 PM
how to change data in worksheet in text without confirming each s. Ronald Excel Discussion (Misc queries) 1 January 17th 05 08:27 AM
Confirming existence of dependents Mike[_65_] Excel Programming 4 January 14th 04 12:25 AM
Confirming existence of dependents Mike[_65_] Excel Programming 0 January 12th 04 09:11 AM
Confirming existence of dependents Mike[_65_] Excel Programming 0 January 11th 04 02:50 PM


All times are GMT +1. The time now is 10:46 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"