Solved

Assign macro to existing button in Excel 2010+

Posted on 2014-02-02
12
2,073 Views
Last Modified: 2014-02-03
Hi,

MS has moved things around so much I can't find this simple thing.  I have an existing button and macro.  I want to assign the macro to the button.  I don't want to create a new button, but use the existing button.

When I have a brand new button I can right-click and it has the option to 'Assign-Macro'.  I don't have that option on this button, and it doesn't seem to be running the macro, so I want to reassign.

How do I assign an existing macro to an existing button?

Thanks!
0
Comment
Question by:ugeb
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
  • 2
  • +1
12 Comments
 
LVL 47

Assisted Solution

by:Martin Liss
Martin Liss earned 100 total points
ID: 39828577
Right-click on the button and choose Assign Macro
0
 
LVL 18

Accepted Solution

by:
Steven Harris earned 400 total points
ID: 39828578
You should be able to use right-click > assign macro.

assign macro
Then pick where the macro is located (this workbook, etc.):

macro location
0
 
LVL 11

Author Comment

by:ugeb
ID: 39828579
As I mentioned, I don't have that option on the button.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 18

Expert Comment

by:Steven Harris
ID: 39828581
If you already have a macro assigned, you will need to remove it.
0
 
LVL 47

Expert Comment

by:Martin Liss
ID: 39828582
Can you attach your project and point out the button you are referring to?
0
 
LVL 18

Expert Comment

by:Steven Harris
ID: 39828583
Or you can just bypass it...

Right-click > view code... > change macro to:
Sub ButtonName_Click()
   macroname
End Sub

Open in new window

Where macroname is the name of the macro you want to run.
0
 
LVL 11

Author Comment

by:ugeb
ID: 39828584
That's part of the infuriating thing about Excel now that I can't figure out.  There is no macro assigned.  When I double click in design mode, it CREATES a stub. I delete the stub, but there is still no option to assign macro.

Also when I try putting in a print statement in the stub, it's not executed.  This is not an old spreadsheet, it's new.  (however it does have confidential info so I can't upload it).
0
 
LVL 18

Expert Comment

by:Steven Harris
ID: 39828602
When I double click in design mode, it CREATES a stub.

Correct.  

Easiest way is to divert using the example above or recreate the button.  Click Cancel when prompted to make a macro, then use the right-click it as shown above.
0
 
LVL 11

Author Comment

by:ugeb
ID: 39828621
Yes, but my point is the stub code is not even executed so there is no diversion possible.  I also don't want to delete the button.

Right clicking gives nothing appropriate.
0
 
LVL 18

Expert Comment

by:Steven Harris
ID: 39828638
I'm going to have to reiterate Martin's question then:

Can you attach your project and point out the button you are referring to?  Even if you save down a limited function copy where only the button and the code exists, removing all sensitive info.
0
 
LVL 11

Author Closing Comment

by:ugeb
ID: 39829017
I actually knew how to do all this stuff, but it didn't work for me, which is why I asked for help here.  I was hoping someone had other ideas because maybe it was just the difference between Excel 2007 and 2010 that was messing me up.  That certainly contributed, but wasn't the real problem.

I think that somehow in my spreadsheet's short life it started hanging out with the wrong crowd and got corrupted.  I can't help but feel partly responsible for its errant ways, but I deleted that bad button.  It crashed Excel, but the recovered file had the juvy deleted.  I didn't want to, but I was forced to create a new button and reformat and align etc., but at least it works now.

Thanks for helping.
0
 
LVL 34

Expert Comment

by:Norie
ID: 39829888
Sounds like you might have an ActiveX button instead of a Forms button.
0

Featured Post

Increase your protection from Zero Day threats!

Running two Antivirus' is never a good idea.
Taking advantage of Multiple Security layers on the other hand can often save your hide.
See which top notch security software brands have been proven to happily coexist together.
Reduce your chances of becoming a statistic.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
office 365 5 45
How to set correct rule in Outlook 2013/2016 1 29
count number 10 30
Office 365 Controls 3 23
Outlook Free & Paid Tools
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

710 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question