ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Range Selection (https://www.excelbanter.com/excel-programming/297764-range-selection.html)

Monsoor

Range Selection
 
Hi All,

What I want to do is simple but can't figure it out. I
have a range as follow:

Dim Rng as Range
Set Rng = Range ("A2:A6")

I want to name this range
Rng.name = "Chart1"

What I want to do is to name the same number of cells in
columns B to AW in the same rows by adding the column
number to the name like above. So range("B2:B6")would be
named as "Chart2". I can do this by:

rng.offset(0,1).name = "Chart2"

This means I will have to do it 49 times! There must be an
easier way of getting the same result. Help is
appreciated. Thanks in advance.

Regards

Monsoor

Norman Jones

Range Selection
 
Hi Monsoor,

Try:

Sub Test()
Dim i As Long

For i = 1 To 49
Range(Cells(1, i), Cells(6, i)).Name = "Charts" & i
Next i

End Sub

---
Regards,
Norman

"Monsoor" wrote in message
...
Hi All,

What I want to do is simple but can't figure it out. I
have a range as follow:

Dim Rng as Range
Set Rng = Range ("A2:A6")

I want to name this range
Rng.name = "Chart1"

What I want to do is to name the same number of cells in
columns B to AW in the same rows by adding the column
number to the name like above. So range("B2:B6")would be
named as "Chart2". I can do this by:

rng.offset(0,1).name = "Chart2"

This means I will have to do it 49 times! There must be an
easier way of getting the same result. Help is
appreciated. Thanks in advance.

Regards

Monsoor





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

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