Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
I have been trying to write a procedure that modifies the primary horizontal axis. Here is the code: Set Charts("Main").Axes(xlCategory).CategoryNames = _ Worksheets("Sheet1").Range("D84:I84") When I try to run it, I get 'Subscript out of Range' Does anyone know what I'm doing wrong? |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Just remove "Set"
Regards, Peter T "R Tanner" wrote in message ... Hi, I have been trying to write a procedure that modifies the primary horizontal axis. Here is the code: Set Charts("Main").Axes(xlCategory).CategoryNames = _ Worksheets("Sheet1").Range("D84:I84") When I try to run it, I get 'Subscript out of Range' Does anyone know what I'm doing wrong? |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
On Jun 23, 8:03 am, "Peter T" <peter_t@discussions wrote:
Just remove "Set" Regards, Peter T "R Tanner" wrote in message ... Hi, I have been trying to write a procedure that modifies the primary horizontal axis. Here is the code: Set Charts("Main").Axes(xlCategory).CategoryNames = _ Worksheets("Sheet1").Range("D84:I84") When I try to run it, I get 'Subscript out of Range' Does anyone know what I'm doing wrong? It still gives me the 'Subscript out of Range' error... |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Try this and report back which line errors and the error description
Sub test() Dim rng As Range Dim cht As Chart Dim ax As Axis Set rng = Worksheets("Sheet1").Range("D84:I84") Set cht = Charts("Main") Set ax = cht.Axes(xlCategory) ax.CategoryNames = rng End Sub Regards, Peter T "R Tanner" wrote in message ... On Jun 23, 8:03 am, "Peter T" <peter_t@discussions wrote: Just remove "Set" Regards, Peter T "R Tanner" wrote in message ... Hi, I have been trying to write a procedure that modifies the primary horizontal axis. Here is the code: Set Charts("Main").Axes(xlCategory).CategoryNames = _ Worksheets("Sheet1").Range("D84:I84") When I try to run it, I get 'Subscript out of Range' Does anyone know what I'm doing wrong? It still gives me the 'Subscript out of Range' error... |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
On Jun 23, 9:45 am, "Peter T" <peter_t@discussions wrote:
Try this and report back which line errors and the error description Sub test() Dim rng As Range Dim cht As Chart Dim ax As Axis Set rng = Worksheets("Sheet1").Range("D84:I84") Set cht = Charts("Main") Set ax = cht.Axes(xlCategory) ax.CategoryNames = rng End Sub Regards, Peter T "R Tanner" wrote in message ... On Jun 23, 8:03 am, "Peter T" <peter_t@discussions wrote: Just remove "Set" Regards, Peter T "R Tanner" wrote in message ... Hi, I have been trying to write a procedure that modifies the primary horizontal axis. Here is the code: Set Charts("Main").Axes(xlCategory).CategoryNames = _ Worksheets("Sheet1").Range("D84:I84") When I try to run it, I get 'Subscript out of Range' Does anyone know what I'm doing wrong? It still gives me the 'Subscript out of Range' error... I'm getting the same error message 'Subcript out of range'. When I go to the selection pane, the name of the chart is 'Chart 1'. This is what I would use in my code, is it not? Thanks |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Is your chart a chart-sheet or is it an embedded chart on a sheet. If it's a
chart-sheet, which is what your original code suggests, in this line Set cht = Charts("Main") ensure "Main" is the name of the chart-sheet or change as necessary But you say - When I go to the selection pane, the name of the chart is 'Chart 1'. This is what I would use in my code, is it not? I don't know what you mean by "selection pane" but what this suggests your chart is an embedded chart. If so start off like this - Set cht = Sheets("sheet-Name").ChartObjects("Chart 1").Chart Regards, Peter T "R Tanner" wrote in message ... On Jun 23, 9:45 am, "Peter T" <peter_t@discussions wrote: Try this and report back which line errors and the error description Sub test() Dim rng As Range Dim cht As Chart Dim ax As Axis Set rng = Worksheets("Sheet1").Range("D84:I84") Set cht = Charts("Main") Set ax = cht.Axes(xlCategory) ax.CategoryNames = rng End Sub Regards, Peter T "R Tanner" wrote in message ... On Jun 23, 8:03 am, "Peter T" <peter_t@discussions wrote: Just remove "Set" Regards, Peter T "R Tanner" wrote in message ... Hi, I have been trying to write a procedure that modifies the primary horizontal axis. Here is the code: Set Charts("Main").Axes(xlCategory).CategoryNames = _ Worksheets("Sheet1").Range("D84:I84") When I try to run it, I get 'Subscript out of Range' Does anyone know what I'm doing wrong? It still gives me the 'Subscript out of Range' error... I'm getting the same error message 'Subcript out of range'. When I go to the selection pane, the name of the chart is 'Chart 1'. This is what I would use in my code, is it not? Thanks |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
On Jun 23, 9:45 am, "Peter T" <peter_t@discussions wrote:
Try this and report back which line errors and the error description Sub test() Dim rng As Range Dim cht As Chart Dim ax As Axis Set rng = Worksheets("Sheet1").Range("D84:I84") Set cht = Charts("Main") Set ax = cht.Axes(xlCategory) ax.CategoryNames = rng End Sub Regards, Peter T "R Tanner" wrote in message ... On Jun 23, 8:03 am, "Peter T" <peter_t@discussions wrote: Just remove "Set" Regards, Peter T "R Tanner" wrote in message ... Hi, I have been trying to write a procedure that modifies the primary horizontal axis. Here is the code: Set Charts("Main").Axes(xlCategory).CategoryNames = _ Worksheets("Sheet1").Range("D84:I84") When I try to run it, I get 'Subscript out of Range' Does anyone know what I'm doing wrong? It still gives me the 'Subscript out of Range' error... I get error 9, and from what I understand, that relates to variable declaration. we have declared all variables in the procedure however. The help menu discusses issues with identifying the array. I'm not sure... |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How can I create a behavior modification chart for children | New Users to Excel | |||
TO CREATE A LINE CHART WITH RATE IN Y AXIS & REAL TIME IN X AXIS | Charts and Charting in Excel | |||
How to place a secondary y axis bar in a bar chart next to two primary y axis bars? | Excel Discussion (Misc queries) | |||
How to place a secondary y axis bar in a bar chart next to two primary y axis bars? | Charts and Charting in Excel | |||
Pivot Table, Line Chart with Secondary Y axis, Page Field selection destroys Y2 axis | Charts and Charting in Excel |