Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 87
Default Chart Axis Modification

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Chart Axis Modification

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 87
Default Chart Axis Modification

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Chart Axis Modification

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 87
Default Chart Axis Modification

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Chart Axis Modification

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 87
Default Chart Axis Modification

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I create a behavior modification chart for children Anthony New Users to Excel 2 June 3rd 09 09:36 PM
TO CREATE A LINE CHART WITH RATE IN Y AXIS & REAL TIME IN X AXIS vijaicbe Charts and Charting in Excel 4 November 9th 06 10:16 AM
How to place a secondary y axis bar in a bar chart next to two primary y axis bars? Dmitry Excel Discussion (Misc queries) 3 May 4th 06 01:58 AM
How to place a secondary y axis bar in a bar chart next to two primary y axis bars? Dmitry Charts and Charting in Excel 2 May 4th 06 01:58 AM
Pivot Table, Line Chart with Secondary Y axis, Page Field selection destroys Y2 axis [email protected] Charts and Charting in Excel 0 July 13th 05 09:30 PM


All times are GMT +1. The time now is 02:13 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"