Solved

Assign macro to existing button in Excel 2010+

Posted on 2014-02-02
12
1,591 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
  • 5
  • 4
  • 2
  • +1
12 Comments
 
LVL 45

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
 
LVL 18

Expert Comment

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

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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
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 33

Expert Comment

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

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
The viewer will learn how to  create a slide that will launch other presentations in Microsoft PowerPoint. In the finished slide, each item launches a new PowerPoint presentation and when each is finished it automatically comes back to this slide: …
Learn how to create and modify your own paragraph styles in Microsoft Word. This can be helpful when wanting to make consistently referenced styles throughout a document or template.

707 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now