Assign a macro Name to a button based off cell reference

G_Sereez

New Member
Joined
May 1, 2014
Messages
39
I have a workbook that copies and moves on sheet to a new workbook and saves it to a selected destination. I have saved code into that sheet so that it carries over to the new workbook. I need to code so that It will assign the macro name to a shape in the workbook.


So the code before editing looks like this:
Selection.OnAction = "Sheet17.PEER_REVIEW_COMPLETED"
The issue is that if someone adds a sheet to the workbook that moved sheet is no longer sheet 17. So, I created a formula in a cell that spits out "Sheet17.PEER_REVIEW_COMPLETED" but the 17 automatically changes based on how many sheets there are. How do I assign the Selection.OnAction to reference that cell?
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
It appears that "Sheet17" is the code name of the sheet and should not change when other sheets are added. What is the formula you use to "spit" out the reference?
 
Upvote 0

Forum statistics

Threads
1,223,632
Messages
6,173,472
Members
452,516
Latest member
archcalx

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top