Dynamic name for a range

ChristineJ

Well-known Member
Joined
May 18, 2009
Messages
602
Office Version
  1. 365
Platform
  1. Windows
Is there a way to make the name of a named range = the worksheet name, and dynamic so that if the worksheet name changes, the name of the named ranges changes as well?

I know I can use =MID(CELL("filename",A1),FIND("]",CELL("filename",A1))+1,255) to get the sheet name in a cell and can use that to "Create from Selection" under "Defined Names" on the ribbon. But that only works to name the range the first time; it is not dynamic.

It would be preferable if this could be done without VBA. Thanks
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"

jasonb75

Well-known Member
Joined
Dec 30, 2008
Messages
12,666
Office Version
  1. 365
Platform
  1. Windows
It would be preferable if this could be done without VBA.
You wouldn't be able to do it without vba.
Even with vba, the idea seems a bit far fetched. The only way to do it would be with a calculate event to create a name based on the result of the formula if one does not already exist.
Deleting the old name could lead to problems. If there are no other named ranges in the workbook then brute force deleting of any named range that is not equal to a sheet name might work, other than that there is too much risk of deleting the wrong names to make the idea practical.
 
Solution

ChristineJ

Well-known Member
Joined
May 18, 2009
Messages
602
Office Version
  1. 365
Platform
  1. Windows
You wouldn't be able to do it without vba.
Even with vba, the idea seems a bit far fetched. The only way to do it would be with a calculate event to create a name based on the result of the formula if one does not already exist.
Deleting the old name could lead to problems. If there are no other named ranges in the workbook then brute force deleting of any named range that is not equal to a sheet name might work, other than that there is too much risk of deleting the wrong names to make the idea practical.
Thanks for the reply and the explanation. I will take your advice and try an alternative to what I was trying to accomplish. Appreciate it.
 

jasonb75

Well-known Member
Joined
Dec 30, 2008
Messages
12,666
Office Version
  1. 365
Platform
  1. Windows
I will take your advice and try an alternative to what I was trying to accomplish.
What is the logic behind the original idea?
Or more specifically, what were you intending to use the name for once it is set up?
 

Watch MrExcel Video

Forum statistics

Threads
1,130,124
Messages
5,640,249
Members
417,131
Latest member
Seanr19871

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
Top