ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Name range example (https://www.excelbanter.com/excel-programming/390714-name-range-example.html)

excelnut1954

Name range example
 
I know this will work to name a range for a single column.

Range(Selection, Selection.End(xlDown)).Name = "Test"

But, how would you adapt it to include the next 3 columns to the
right?

Thanks,
J.O.


Tom Ogilvy

Name range example
 
Use Resize:

Range(Selection, Selection.End(xlDown)).Resize(,3).Name = "Test"

for a total of 3 columns. Change the 3 to a 4 if it is 3 additional columns.

--
Regards,
Tom Ogilvy


"excelnut1954" wrote:

I know this will work to name a range for a single column.

Range(Selection, Selection.End(xlDown)).Name = "Test"

But, how would you adapt it to include the next 3 columns to the
right?

Thanks,
J.O.



excelent

Name range example
 
Range(Selection.Resize(1, 3), Selection.End(xlDown)).Name = "Test"


"Tom Ogilvy" skrev:

Use Resize:

Range(Selection, Selection.End(xlDown)).Resize(,3).Name = "Test"

for a total of 3 columns. Change the 3 to a 4 if it is 3 additional columns.

--
Regards,
Tom Ogilvy


"excelnut1954" wrote:

I know this will work to name a range for a single column.

Range(Selection, Selection.End(xlDown)).Name = "Test"

But, how would you adapt it to include the next 3 columns to the
right?

Thanks,
J.O.




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

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