ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Creating range name for a range selection (https://www.excelbanter.com/excel-programming/289180-creating-range-name-range-selection.html)

Mervyn Thomas

Creating range name for a range selection
 
My existing code is a bit predetermined as in the example:

ActiveWorkbook.Names.Add Name:="CodeLookup",
RefersToR1C1:="=CostCodes!R1C2:R200C8"

I can't figure out how to change this to refer to the current region
selection such as:

ActiveWorkbook.Names.Add Name:="CodeLookup", RefersToR1C1;= current
selection

Mervyn



John Wilson

Creating range name for a range selection
 
Mervyn,

Try this out:

Range("A1").CurrentRegion.Name = "TestRange"

John

"Mervyn Thomas" wrote in message
...
My existing code is a bit predetermined as in the example:

ActiveWorkbook.Names.Add Name:="CodeLookup",
RefersToR1C1:="=CostCodes!R1C2:R200C8"

I can't figure out how to change this to refer to the current region
selection such as:

ActiveWorkbook.Names.Add Name:="CodeLookup", RefersToR1C1;= current
selection

Mervyn






All times are GMT +1. The time now is 10:49 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com