hi - thank you - I always get great responses on Mr Excel
This is an easy question, but having trouble finding the solution
I want to name a range based on variables that have the Sheet name, Range that I want to define, Name that I want to assign
The code below does not work.
Also, what would the code be to duplicate a range name (not change) so that the oldname stays and the new names is also there
THANK YOU
Dim R As String
Dim NewName As String
Dim OldName As String
Dim TheSheet As String
Dim TheCells As String
NewName = "TheNewName"
TheSheet = "Sheet1"
TheCells = "$X$1:$Z$2"
R = "'" + TheSheet + "'!" & TheCells
ActiveWorkbook.Names.Add Name:=NewName, RefersTo:=Range(R)
This is an easy question, but having trouble finding the solution
I want to name a range based on variables that have the Sheet name, Range that I want to define, Name that I want to assign
The code below does not work.
Also, what would the code be to duplicate a range name (not change) so that the oldname stays and the new names is also there
THANK YOU
Dim R As String
Dim NewName As String
Dim OldName As String
Dim TheSheet As String
Dim TheCells As String
NewName = "TheNewName"
TheSheet = "Sheet1"
TheCells = "$X$1:$Z$2"
R = "'" + TheSheet + "'!" & TheCells
ActiveWorkbook.Names.Add Name:=NewName, RefersTo:=Range(R)