Solved

Assign macro to existing button in Excel 2010+

Posted on 2014-02-02
12
2,236 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 48

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
Office 365 Training for Admins - 7 Day Trial

Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies.  Only from Platform Scholar.

 
LVL 18

Expert Comment

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

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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

Excel can be a tricky bit of software to get your head around. Whilst you’ll be able to eventually get to grips with the basic understanding of how to get by, there are a few Excel tips that not everybody will even know about let alone know how to d…
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

617 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