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

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
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,214,386
Messages
6,119,217
Members
448,876
Latest member
Solitario

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