ExcelTip.com
Account Icon Account Icon Account Icon
ExcelTip.com

Go Back   Excel Help Forum > Microsoft Office Application Help - Excel Help forum > Excel Programming > Excel Charting

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 02-16-2005, 05:21 AM
konpego
Guest
 
Posts: n/a
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
Reply With Quote
  #2  
Old 02-16-2005, 10:42 AM
Jon Peltier
Guest
 
Posts: n/a
Re: Error when more than 60 items on X-axis

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 With Quote
  #3  
Old 02-18-2005, 10:06 AM
konpego
Guest
 
Posts: n/a
Re: Error when more than 60 items on X-axis

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 With Quote
  #4  
Old 02-18-2005, 10:06 AM
Jon Peltier
Guest
 
Posts: n/a
Re: Error when more than 60 items on X-axis

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 With Quote
Reply

Bookmarks

New topics in Excel Charting


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off
Forum Jump


All times are GMT -4. The time now is 04:23 PM.


Powered by vBulletin® Version 3.7.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0