L
Luce
I have 4 named ranges that relate to a column of data starting on row 1 going
to the end of the column data.
The columns may resize periodically since rows of data will be added. How
do I write code that will name the range taking into account that each of the
columns may resize and the range, therefore, will need to resize. If I use
"Current Region" it selects the whole table of data since the columns are
contiguous. I only want the range to select a column of data.
I am currently using the following code to name ranges...but it is not
dynamic if the column resizes by adding another row.
Range("A1").Select
Range(Selection, Selection.End(xlDown)).Select
ActiveWorkbook.Names.Add Name:="ID", RefersToR1C1:= _
"=Assignment!R1C1:R34C1"
Range("B1").Select
Range(Selection, Selection.End(xlDown)).Select
ActiveWorkbook.Names.Add Name:="ZLow", RefersToR1C1:= _
"Assignment!R1C2:R34C2"
Range("C1").Select
Range(Selection, Selection.End(xlDown)).Select
ActiveWorkbook.Names.Add Name:="ZHigh", RefersToR1C1:= _
"=Assignment!R1C3:R34C3"
Range("D1").Select
Range(Selection, Selection.End(xlDown)).Select
ActiveWorkbook.Names.Add Name:="Dnt", RefersToR1C1:= _
"=Assignment!R1C4:R34C4"
to the end of the column data.
The columns may resize periodically since rows of data will be added. How
do I write code that will name the range taking into account that each of the
columns may resize and the range, therefore, will need to resize. If I use
"Current Region" it selects the whole table of data since the columns are
contiguous. I only want the range to select a column of data.
I am currently using the following code to name ranges...but it is not
dynamic if the column resizes by adding another row.
Range("A1").Select
Range(Selection, Selection.End(xlDown)).Select
ActiveWorkbook.Names.Add Name:="ID", RefersToR1C1:= _
"=Assignment!R1C1:R34C1"
Range("B1").Select
Range(Selection, Selection.End(xlDown)).Select
ActiveWorkbook.Names.Add Name:="ZLow", RefersToR1C1:= _
"Assignment!R1C2:R34C2"
Range("C1").Select
Range(Selection, Selection.End(xlDown)).Select
ActiveWorkbook.Names.Add Name:="ZHigh", RefersToR1C1:= _
"=Assignment!R1C3:R34C3"
Range("D1").Select
Range(Selection, Selection.End(xlDown)).Select
ActiveWorkbook.Names.Add Name:="Dnt", RefersToR1C1:= _
"=Assignment!R1C4:R34C4"