Named Range names linked to cell

Paul Sansom

Board Regular
Joined
Jan 28, 2013
Messages
178
Office Version
  1. 2021
  2. 2016
Platform
  1. Windows
Hi
Is it possible to link the name of a named workbook range to a cell on a sheet.
I would like to make the name of the range dynamic?

When the title of my named ranges change i currently have to rename all the Named Range Names as well.

All ideas appreciated
Cheers Paul
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
I think I understand what you want to do, This code will change then name of a named range where the name is given by the text in cell A1
You will need to define the named range first and then write the Name of it in cell A1. If the name is the same it doesn't change it.
Code:
Public previousname As String

Private Sub Worksheet_Change(ByVal Target As Range)
   
If Target.Address = "$A$1" Then
    If Cells(1, 1) <> previousname Then
    ActiveWorkbook.Names.Add Name:=Cells(1, 1), RefersTo:=ActiveWorkbook.Names(previousname)
    ActiveWorkbook.Names(previousname).Delete
    End If
   End If


End Sub


Private Sub Worksheet_SelectionChange(ByVal Target As Range)
   If Target.Address = "$A$1" Then
     previousname = Cells(1, 1)
    End If
End Sub
 
Upvote 0
Yes thanks, i get this.
Compare the name value and then reset previousname to current value if the cell is selected before any change.
Sweet....... Many thanks
 
Upvote 0

Forum statistics

Threads
1,223,640
Messages
6,173,501
Members
452,517
Latest member
SoerenB

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