PC Review


Reply
Thread Tools Rate Thread

Chart Axis Modification

 
 
R Tanner
Guest
Posts: n/a
 
      23rd Jun 2008
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?
 
Reply With Quote
 
 
 
 
Peter T
Guest
Posts: n/a
 
      23rd Jun 2008
Just remove "Set"

Regards,
Peter T


"R Tanner" <(E-Mail Removed)> 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?



 
Reply With Quote
 
R Tanner
Guest
Posts: n/a
 
      23rd Jun 2008
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...
 
Reply With Quote
 
Peter T
Guest
Posts: n/a
 
      23rd Jun 2008
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" <(E-Mail Removed)> 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...



 
Reply With Quote
 
R Tanner
Guest
Posts: n/a
 
      23rd Jun 2008
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
 
Reply With Quote
 
R Tanner
Guest
Posts: n/a
 
      23rd Jun 2008
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 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 With Quote
 
Peter T
Guest
Posts: n/a
 
      23rd Jun 2008
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



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
TO CREATE A LINE CHART WITH RATE IN Y AXIS & REAL TIME IN X AXIS =?Utf-8?B?dmlqYWljYmU=?= Microsoft Excel Charting 4 9th Nov 2006 10:16 AM
How to place a secondary y axis bar in a bar chart next to two primary y axis bars? Dmitry Microsoft Excel Discussion 1 4th May 2006 01:58 AM
How to place a secondary y axis bar in a bar chart next to two primary y axis bars? Dmitry Microsoft Excel Misc 3 4th May 2006 01:58 AM
How to place a secondary y axis bar in a bar chart next to two primary y axis bars? Dmitry Microsoft Excel Charting 2 4th May 2006 01:58 AM
Pivot Table, Line Chart with Secondary Y axis, Page Field selection destroys Y2 axis mw210461@yahoo.com Microsoft Excel Charting 0 13th Jul 2005 09:30 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:57 PM.