Limiting a Button to a single workbook

  • Thread starter Thread starter Mark
  • Start date Start date
M

Mark

I have created a macro in a workbook and assigned it to a
custom button that appears on my Macros toolbar.

This works great for what I want to do but I only need
the macro/button to show up in this one workbook.

Now, whenever I create a new workbook, the custom button
shows.

Is there any way I can limit it to just the workbook I
specify?

Thanks!
 
When you save your macro there is a box to tell it to
save in your personal workbook or save it in this
workbook only. Select this workbook only and then delete
it out of your personal workbook
 
Thanks for your reply. Yes, I did this. I saved the
macro in "This Workbook Only". But, I also have a button
that has that macro assigned. The button is what's
appearing in every new workbook I create. Even though I
specified the macro only for the one workbook - the
button runs the macro in anything I create.
 
You could do some fancy stuff hiding the button (or toolbar if it has its own
toolbar) using workbook events, but you may want to weasel out.

Add something like:

if activeworkbook.name <> thisworkbook.name then
msgbox "not for this workbook, buddy"
exit sub
end if

near the top.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top