Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2658
  • Last Modified:

Assign macro to existing button in Excel 2010+

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
ugeb
Asked:
ugeb
  • 5
  • 4
  • 2
  • +1
2 Solutions
 
Martin LissRetired ProgrammerCommented:
Right-click on the button and choose Assign Macro
0
 
Steven HarrisPresidentCommented:
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
 
ugebAuthor Commented:
As I mentioned, I don't have that option on the button.
0
NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

 
Steven HarrisPresidentCommented:
If you already have a macro assigned, you will need to remove it.
0
 
Martin LissRetired ProgrammerCommented:
Can you attach your project and point out the button you are referring to?
0
 
Steven HarrisPresidentCommented:
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
 
ugebAuthor Commented:
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
 
Steven HarrisPresidentCommented:
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
 
ugebAuthor Commented:
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
 
Steven HarrisPresidentCommented:
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
 
ugebAuthor Commented:
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
 
NorieCommented:
Sounds like you might have an ActiveX button instead of a Forms button.
0

Featured Post

Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

  • 5
  • 4
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now