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" <(E-Mail Removed)> wrote in message
news:75a0c217-7ab6-49d9-84d2-(E-Mail Removed)...
> 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" <tanner.ro...@gmail.com> wrote in message
> >
> >
news:c999cc47-e5b8-44cc-a16e-(E-Mail Removed)...>
On Jun 23, 8:03 am, "Peter T" <peter_t@discussions> wrote:
> > > > Just remove "Set"
> >
> > > > Regards,
> > > > Peter T
> >
> > > > "R Tanner" <tanner.ro...@gmail.com> wrote in message
> >
> >
news:551f8827-b033-4347-886a-(E-Mail Removed)...
> >
> >
> >
> > > > > 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
|