G
Guest
I'm trying to select a range and name it but i just cant do it
The range isn't always the same, it can start in R5C1 and ends at R27C76, or
R7C1 to R150C12.
Range("A1").Select
Selection.End(xlDown).Select
' this is where the data range begins
Selection.End(xlDown).Select
FirstRow = Selection.Row
Selection.End(xlDown).Select
LastRow = Selection.Row
Range("A1").Select
Selection.End(xlDown).Select
Selection.End(xlDown).Select
FirstColumn = Selection.Column
Selection.End(xlToRight).Select
LastColumn = Selection.Column
After getting the range i would like to name it, like this
ActiveWorkbook.Names.Add Name:="DataRange",
RefersToR1C1:="=Sheet4!R5C1:R35C10"
How can i set the ..., "RefersToR1C1:="=Sheet4!R5C1:R35C10"" to my DataRange
selected above?
I'm sure theres a very easy way to do this but i'm new in VBA
Thanks
PC
The range isn't always the same, it can start in R5C1 and ends at R27C76, or
R7C1 to R150C12.
Range("A1").Select
Selection.End(xlDown).Select
' this is where the data range begins
Selection.End(xlDown).Select
FirstRow = Selection.Row
Selection.End(xlDown).Select
LastRow = Selection.Row
Range("A1").Select
Selection.End(xlDown).Select
Selection.End(xlDown).Select
FirstColumn = Selection.Column
Selection.End(xlToRight).Select
LastColumn = Selection.Column
After getting the range i would like to name it, like this
ActiveWorkbook.Names.Add Name:="DataRange",
RefersToR1C1:="=Sheet4!R5C1:R35C10"
How can i set the ..., "RefersToR1C1:="=Sheet4!R5C1:R35C10"" to my DataRange
selected above?
I'm sure theres a very easy way to do this but i'm new in VBA
Thanks
PC