Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
konpego
 
Posts: n/a
Default Error when more than 60 items on X-axis

Hello,

I want to present three line-curves over a number of weeks. And I have the
following code in my VB-program:

ReDim WeekAxis(1 To iLastWeek) As Integer
..... (calculate ranges)
' Create Chart on new Worksheet (Left, Top, Width, Height)
Set ch = Worksheets("TempGraph").ChartObjects.Add(5, 5, 600, 350)

ch.Chart.ChartWizard Source:=Worksheets("TempGraph").Range("a60:t62"), _
gallery:=xlLine, Title:="Deliverables versus time"

ch.Chart.SetSourceData Source:=Worksheets("TempGraph").Range("A60"). _
Resize(cNumRows, iNumCols)

' X-axis title and Category
With ch.Chart.Axes(xlCategory)
.CategoryNames = WeekAxis
.HasTitle = True
.AxisTitle.Text = "Week"
End With

The problem is when I dimension my "WeekAxis" variable:
- When "iLastWeek" is 59 or less everything works OK
But
- When "iLastWeek" is 60 or more I get an error

Has anybody any ideas about this?
Do you need more info to understand my problem?

/konpego
  #2   Report Post  
Jon Peltier
 
Posts: n/a
Default

Is 'WeekAxis' a VBA array? There is a limit to how many characters Excel
will accept in the definition of XValues or Values, and apparently
CategoryNames, which I rarely use. They must be short names, 2-3
characters each, or you'd crash well before 59 elements.

Put this array into a worksheet range, and use this range for your
CategoryNames.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Peltier Technical Services
Tutorials and Custom Solutions
http://PeltierTech.com/
_______

konpego wrote:

Hello,

I want to present three line-curves over a number of weeks. And I have the
following code in my VB-program:

ReDim WeekAxis(1 To iLastWeek) As Integer
.... (calculate ranges)
' Create Chart on new Worksheet (Left, Top, Width, Height)
Set ch = Worksheets("TempGraph").ChartObjects.Add(5, 5, 600, 350)

ch.Chart.ChartWizard Source:=Worksheets("TempGraph").Range("a60:t62"), _
gallery:=xlLine, Title:="Deliverables versus time"

ch.Chart.SetSourceData Source:=Worksheets("TempGraph").Range("A60"). _
Resize(cNumRows, iNumCols)

' X-axis title and Category
With ch.Chart.Axes(xlCategory)
.CategoryNames = WeekAxis
.HasTitle = True
.AxisTitle.Text = "Week"
End With

The problem is when I dimension my "WeekAxis" variable:
- When "iLastWeek" is 59 or less everything works OK
But
- When "iLastWeek" is 60 or more I get an error

Has anybody any ideas about this?
Do you need more info to understand my problem?

/konpego

  #3   Report Post  
konpego
 
Posts: n/a
Default

Thanks Jon,

But I need more info (only the average VB_Excel programmer!).

I know that my range starts at e.g "A50" but I only know
that it contains, lets say 65 weeks.
How do I translate my array /that has been dimensioned to
"1 to 65" into a range starting at "A50".
The array already exists as a WS range but I don't know
how to translate into a range...?

Please help me!

/konpego

"Jon Peltier" wrote:

Is 'WeekAxis' a VBA array? There is a limit to how many characters Excel
will accept in the definition of XValues or Values, and apparently
CategoryNames, which I rarely use. They must be short names, 2-3
characters each, or you'd crash well before 59 elements.

Put this array into a worksheet range, and use this range for your
CategoryNames.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Peltier Technical Services
Tutorials and Custom Solutions
http://PeltierTech.com/
_______

konpego wrote:

Hello,

I want to present three line-curves over a number of weeks. And I have the
following code in my VB-program:

ReDim WeekAxis(1 To iLastWeek) As Integer
.... (calculate ranges)
' Create Chart on new Worksheet (Left, Top, Width, Height)
Set ch = Worksheets("TempGraph").ChartObjects.Add(5, 5, 600, 350)

ch.Chart.ChartWizard Source:=Worksheets("TempGraph").Range("a60:t62"), _
gallery:=xlLine, Title:="Deliverables versus time"

ch.Chart.SetSourceData Source:=Worksheets("TempGraph").Range("A60"). _
Resize(cNumRows, iNumCols)

' X-axis title and Category
With ch.Chart.Axes(xlCategory)
.CategoryNames = WeekAxis
.HasTitle = True
.AxisTitle.Text = "Week"
End With

The problem is when I dimension my "WeekAxis" variable:
- When "iLastWeek" is 59 or less everything works OK
But
- When "iLastWeek" is 60 or more I get an error

Has anybody any ideas about this?
Do you need more info to understand my problem?

/konpego


  #4   Report Post  
Jon Peltier
 
Posts: n/a
Default

This fills the value of MyArray into the sheet, in a vertical range
starting at A50, extending far enough to hold all elements of MyArray:

ActiveSheet.Range("A50").resize(UBound(MyArray,1)+ 1-LBound(MyArray,1)) _
.Value = MyArray

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Peltier Technical Services
Tutorials and Custom Solutions
http://PeltierTech.com/
_______


konpego wrote:
Thanks Jon,

But I need more info (only the average VB_Excel programmer!).

I know that my range starts at e.g "A50" but I only know
that it contains, lets say 65 weeks.
How do I translate my array /that has been dimensioned to
"1 to 65" into a range starting at "A50".
The array already exists as a WS range but I don't know
how to translate into a range...?

Please help me!

/konpego

"Jon Peltier" wrote:


Is 'WeekAxis' a VBA array? There is a limit to how many characters Excel
will accept in the definition of XValues or Values, and apparently
CategoryNames, which I rarely use. They must be short names, 2-3
characters each, or you'd crash well before 59 elements.

Put this array into a worksheet range, and use this range for your
CategoryNames.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Peltier Technical Services
Tutorials and Custom Solutions
http://PeltierTech.com/
_______

konpego wrote:


Hello,

I want to present three line-curves over a number of weeks. And I have the
following code in my VB-program:

ReDim WeekAxis(1 To iLastWeek) As Integer
.... (calculate ranges)
' Create Chart on new Worksheet (Left, Top, Width, Height)
Set ch = Worksheets("TempGraph").ChartObjects.Add(5, 5, 600, 350)

ch.Chart.ChartWizard Source:=Worksheets("TempGraph").Range("a60:t62"), _
gallery:=xlLine, Title:="Deliverables versus time"

ch.Chart.SetSourceData Source:=Worksheets("TempGraph").Range("A60"). _
Resize(cNumRows, iNumCols)

' X-axis title and Category
With ch.Chart.Axes(xlCategory)
.CategoryNames = WeekAxis
.HasTitle = True
.AxisTitle.Text = "Week"
End With

The problem is when I dimension my "WeekAxis" variable:
- When "iLastWeek" is 59 or less everything works OK
But
- When "iLastWeek" is 60 or more I get an error

Has anybody any ideas about this?
Do you need more info to understand my problem?

/konpego


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
change axis info on radar charts alfred Charts and Charting in Excel 1 January 11th 05 04:36 AM
space between y axis and data points.. Dave R. Charts and Charting in Excel 3 January 8th 05 04:56 AM
Second X axis at top of chart? Phil Hageman Charts and Charting in Excel 1 December 29th 04 01:48 PM
Labels on Chart with Negative Value Axis David F. Schrader Charts and Charting in Excel 6 December 17th 04 06:25 PM
Graphing Reversing the Axis Michael R Middleton Setting up and Configuration of Excel 0 November 30th 04 10:59 PM


All times are GMT +1. The time now is 03:35 PM.

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

About Us

"It's about Microsoft Excel"