ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Change range name (https://www.excelbanter.com/excel-programming/304988-change-range-name.html)

Al Eaton

Change range name
 
I have a series of dynamic range names (i.e.. PX1, PX2, PX3, PX4, ect). I
want to set up a loop to use each range name. I tried something like this
which does not work:


Dim RngNbr As Integer, iRow As Integer
RngNbr = 1
Sheets("HistData").Select
'Select range PX1, PX2, PX3, PX4 by changing the value of RngNbr
Set pxRge = Range("PX & RngNbr")

ActiveSheet.ChartObjects("Chart 41").Activate
With ActiveChart.Axes(xlValue)
.MinimumScale = 0.97 *
Application.WorksheetFunction.Min(pxRge)
.Crosses = xlCustom
.CrossesAt = 0
.ReversePlotOrder = False
.ScaleType = xlLinear
End With

Any ideas? I would also like the select different charts with a similar
method.
--

Al Eaton




Tom Ogilvy

Change range name
 
No obvious reason that shouldn't work. If you defined a name as PX1 in the
activeworkbook, then

i = 1
set rng = range("PX" & i)


should work fine.

--
Regards,
Tom Ogilvy


"Al Eaton" wrote in message
...
I have a series of dynamic range names (i.e.. PX1, PX2, PX3, PX4, ect). I
want to set up a loop to use each range name. I tried something like this
which does not work:


Dim RngNbr As Integer, iRow As Integer
RngNbr = 1
Sheets("HistData").Select
'Select range PX1, PX2, PX3, PX4 by changing the value of RngNbr
Set pxRge = Range("PX & RngNbr")

ActiveSheet.ChartObjects("Chart 41").Activate
With ActiveChart.Axes(xlValue)
.MinimumScale = 0.97 *
Application.WorksheetFunction.Min(pxRge)
.Crosses = xlCustom
.CrossesAt = 0
.ReversePlotOrder = False
.ScaleType = xlLinear
End With

Any ideas? I would also like the select different charts with a similar
method.
--

Al Eaton







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

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