ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Excel macro to insert names for ranges, not always the same size.. (https://www.excelbanter.com/excel-programming/320467-excel-macro-insert-names-ranges-not-always-same-size.html)

Ocicat

Excel macro to insert names for ranges, not always the same size..
 
I need an Exel macro to insert names for ranges, not always the same size.
They always start in Colunn A and end in Column U.

gocush[_28_]

Excel macro to insert names for ranges, not always the same size..
 
ActiveWorkbook.Names.Add Name:="MyRange1", RefersToR1C1:= _
"=Sheet1!R2C1:R2C21"

will insert the name: MyRange1
and will refer to the cells A2:U2


"Ocicat" wrote:

I need an Exel macro to insert names for ranges, not always the same size.
They always start in Colunn A and end in Column U.


Shadhi

Excel macro to insert names for ranges, not always the same si
 
You could also try:
Dim myRange as Range

set myRange = Workbooks(1).Sheets(1).Range("A1:U1")
myRange.Name = "MyRange"

"gocush" wrote:

ActiveWorkbook.Names.Add Name:="MyRange1", RefersToR1C1:= _
"=Sheet1!R2C1:R2C21"

will insert the name: MyRange1
and will refer to the cells A2:U2


"Ocicat" wrote:

I need an Exel macro to insert names for ranges, not always the same size.
They always start in Colunn A and end in Column U.



All times are GMT +1. The time now is 06:25 AM.

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