Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 407
Default Inadvertent macro

I have come to love these buttons you can make for users, so that they can easily run a macro. However, I have noticed that it is all too easy for some users to inadvertently put one's mouse button over the button and run a macro that one didn't mean to.

Can someone tell me the code to copy into the beginning of each macro so that it will ask the user if he or she really wants to run this macro? If the user chooses "No" it will not run the macro.

Thanks much!
Dean
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Inadvertent macro

sub DoStuff

if msgbox("do you wnat to do stuff?", vbyesno, "Do Stuff?) = vbno then
msgbox "Stuff was not done"
else
'do your stuff
end if

end sub
--
HTH...

Jim Thomlinson


"Dean" wrote:

I have come to love these buttons you can make for users, so that they can easily run a macro. However, I have noticed that it is all too easy for some users to inadvertently put one's mouse button over the button and run a macro that one didn't mean to.

Can someone tell me the code to copy into the beginning of each macro so that it will ask the user if he or she really wants to run this macro? If the user chooses "No" it will not run the macro.

Thanks much!
Dean

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 407
Default Inadvertent macro

Sorry for my novicity (is that a word), but I need a little more guidance,
please (and thank you). By writing this as a subroutine, you seem to be
suggesting that its text doesn't need to be copied into every macro, which
would be nice. If you didn't mean to imply that, please let me know.

If you did mean to imply that, then I assume the 'do your stuff statement
really needs to be some way for the Do Stuff subroutine to hand control back
over to the subroutine that calls it (assuming the user chooses to
continue). Can you rewrite your macro to do that? Perhaps it's some
statement like "return" or continue (with calling subroutine).

Also, can you please be careful to get all spaces and syntax exact as I
would like to be able to copy your text in directly.

Thanks so much! Despite the holiday, I am not quite "independent" from
needing trivial help, yet!

Dean

"Jim Thomlinson" wrote in message
...
sub DoStuff

if msgbox("do you wnat to do stuff?", vbyesno, "Do Stuff?) = vbno then
msgbox "Stuff was not done"
else
'do your stuff
end if

end sub
--
HTH...

Jim Thomlinson


"Dean" wrote:

I have come to love these buttons you can make for users, so that they
can easily run a macro. However, I have noticed that it is all too easy
for some users to inadvertently put one's mouse button over the button
and run a macro that one didn't mean to.

Can someone tell me the code to copy into the beginning of each macro so
that it will ask the user if he or she really wants to run this macro?
If the user chooses "No" it will not run the macro.

Thanks much!
Dean



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Inadvertent macro

The code that I posted is intended to be added to the code for each button
that you have. (You can tailor the message box to the specifics of each
button this way if you wish.) Right now (I assume that you are attaching the
button to code which you have stored in a module) your button is attached to
say "Macro1". Take the code that I posted and insert it into "Macro1"...
something like this...

sub Macro1

if msgbox("do you want to do stuff?", vbyesno, "Do Stuff?) = vbno then
msgbox "Stuff was not done"
else
'Your existing macro1 code...
end if

end sub
--
HTH...

Jim Thomlinson


"Dean" wrote:

Sorry for my novicity (is that a word), but I need a little more guidance,
please (and thank you). By writing this as a subroutine, you seem to be
suggesting that its text doesn't need to be copied into every macro, which
would be nice. If you didn't mean to imply that, please let me know.

If you did mean to imply that, then I assume the 'do your stuff statement
really needs to be some way for the Do Stuff subroutine to hand control back
over to the subroutine that calls it (assuming the user chooses to
continue). Can you rewrite your macro to do that? Perhaps it's some
statement like "return" or continue (with calling subroutine).

Also, can you please be careful to get all spaces and syntax exact as I
would like to be able to copy your text in directly.

Thanks so much! Despite the holiday, I am not quite "independent" from
needing trivial help, yet!

Dean

"Jim Thomlinson" wrote in message
...
sub DoStuff

if msgbox("do you wnat to do stuff?", vbyesno, "Do Stuff?) = vbno then
msgbox "Stuff was not done"
else
'do your stuff
end if

end sub
--
HTH...

Jim Thomlinson


"Dean" wrote:

I have come to love these buttons you can make for users, so that they
can easily run a macro. However, I have noticed that it is all too easy
for some users to inadvertently put one's mouse button over the button
and run a macro that one didn't mean to.

Can someone tell me the code to copy into the beginning of each macro so
that it will ask the user if he or she really wants to run this macro?
If the user chooses "No" it will not run the macro.

Thanks much!
Dean




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Inadvertent macro

Dean,

Try some code like the following at the top of each sub:

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


"Dean" wrote in message
...
I have come to love these buttons you can make for users, so that
they can easily run a macro. However, I have noticed that it is
all too easy for some users to inadvertently put one's mouse
button over the button and run a macro that one didn't mean to.

Can someone tell me the code to copy into the beginning of each
macro so that it will ask the user if he or she really wants to
run this macro? If the user chooses "No" it will not run the
macro.

Thanks much!
Dean




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 407
Default Inadvertent macro

Thanks Chip (and Jim). That works really well for a simple mind like mine!

Dean

"Chip Pearson" wrote in message
...
Dean,

Try some code like the following at the top of each sub:

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


"Dean" wrote in message
...
I have come to love these buttons you can make for users, so that they can
easily run a macro. However, I have noticed that it is all too easy for
some users to inadvertently put one's mouse button over the button and run
a macro that one didn't mean to.

Can someone tell me the code to copy into the beginning of each macro so
that it will ask the user if he or she really wants to run this macro? If
the user chooses "No" it will not run the macro.

Thanks much!
Dean



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
Macro recorded... tabs & file names changed, macro hangs Steve Excel Worksheet Functions 3 October 30th 09 11:41 AM
inadvertent external links when copy/pasting JB Excel Discussion (Misc queries) 3 March 7th 09 08:56 PM
Macro Help Needed - Excel 2007 - Print Macro with Auto Sort Gavin Excel Worksheet Functions 0 May 17th 07 01:20 PM
macro to delete entire rows when column A is blank ...a quick macro vikram Excel Programming 4 May 3rd 04 08:45 PM
Start Macro / Stop Macro / Restart Macro Pete[_13_] Excel Programming 2 November 21st 03 05:04 PM


All times are GMT +1. The time now is 10:29 PM.

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

About Us

"It's about Microsoft Excel"