Home All Groups Group Topic Archive Search About

X-axis value of Excel chart

Author
22 May 2005 2:35 PM
Kate
I have problem with assigning x-axis value of a chart.

This is how I assign y-axis value. LastCell is a variable.
xlCht1.SeriesCollection(1).XValues = xlWshtS.Range("E4:E" & LastCell)

I know this can assign values for both axes, but it can't use LastCell.
xlCht1.SeriesCollection(1).XValues = xlWshtS!"R4C1:R10C1"

Any suggestion?

Thanks,
Kate

Author
22 May 2005 7:47 PM
Kevan Hughes
Kate,

Try switching off the R1C1 reference style.. Are you using Visual Basic 6 or
VBA ?

Kevan

Show quoteHide quote
"Kate" wrote:

> I have problem with assigning x-axis value of a chart.
>
> This is how I assign y-axis value. LastCell is a variable.
> xlCht1.SeriesCollection(1).XValues = xlWshtS.Range("E4:E" & LastCell)
>
> I know this can assign values for both axes, but it can't use LastCell.
> xlCht1.SeriesCollection(1).XValues = xlWshtS!"R4C1:R10C1"
>
> Any suggestion?
>
> Thanks,
> Kate
Author
23 May 2005 2:52 PM
Kate
I use VB6.  How to switch off R1C1? and even if it's switched off, I still
don't know how to assign value for x-axis...

Thanks,
Kate

Show quoteHide quote
"Kevan Hughes" wrote:

> Kate,
>
> Try switching off the R1C1 reference style.. Are you using Visual Basic 6 or
> VBA ?
>
> Kevan
>
> "Kate" wrote:
>
> > I have problem with assigning x-axis value of a chart.
> >
> > This is how I assign y-axis value. LastCell is a variable.
> > xlCht1.SeriesCollection(1).XValues = xlWshtS.Range("E4:E" & LastCell)
> >
> > I know this can assign values for both axes, but it can't use LastCell.
> > xlCht1.SeriesCollection(1).XValues = xlWshtS!"R4C1:R10C1"
> >
> > Any suggestion?
> >
> > Thanks,
> > Kate
Author
23 May 2005 5:11 PM
Kevan Hughes
In Excel use TOOLS, OPTIONS then General.. Settings show R1C1.. uncheck the
box.. I gather you want to create a graph ?

Show quoteHide quote
"Kate" wrote:

> I use VB6.  How to switch off R1C1? and even if it's switched off, I still
> don't know how to assign value for x-axis...
>
> Thanks,
> Kate
>
> "Kevan Hughes" wrote:
>
> > Kate,
> >
> > Try switching off the R1C1 reference style.. Are you using Visual Basic 6 or
> > VBA ?
> >
> > Kevan
> >
> > "Kate" wrote:
> >
> > > I have problem with assigning x-axis value of a chart.
> > >
> > > This is how I assign y-axis value. LastCell is a variable.
> > > xlCht1.SeriesCollection(1).XValues = xlWshtS.Range("E4:E" & LastCell)
> > >
> > > I know this can assign values for both axes, but it can't use LastCell.
> > > xlCht1.SeriesCollection(1).XValues = xlWshtS!"R4C1:R10C1"
> > >
> > > Any suggestion?
> > >
> > > Thanks,
> > > Kate
Author
24 May 2005 6:41 AM
Kate
R1C1 is already off.
Yes, I'm trying to create a chart.  Sorry that I didn't state it clearly.

For example, the chart type is xlColumnClustered. The range of y-axis is
colB, colC, and colD, from row1 to rowVariable. The range of x-axis is colA,
from row1 to rowVariable.  How to create a chart like that?

Now, I use:
xlCht1.ChartType = xlColumnClustered
xlCht1.SeriesCollection(1).XValues = xlWshtS.Range("B1:B" & rowVariable)
The chart looks fine, except that the value of x-axis is missing.

Thanks
Kate

Show quoteHide quote
"Kevan Hughes" wrote:

> In Excel use TOOLS, OPTIONS then General.. Settings show R1C1.. uncheck the
> box.. I gather you want to create a graph ?
>
Author
24 May 2005 8:32 AM
Kevan Hughes
Kate, take a look at a sample.. You be missing a string declaration. Sample
is loaded when installing VB locally..  should be \VB98\SAMPLES\VB98\CHRSAMP
folder. The MODCHART.BAS is the code you should look at, DATE VALUES are used
for x-axis labels/values.. IS this useful ?

Public Sub PopOneArray(thisarray As Variant, col As String)
    ' This procedure just populates arrays.
    Dim i As Integer
    ReDim thisarray(1 To intRows, 1 To 2)
    For i = 1 To intRows
        ' Get the Date values.
        thisarray(i, 1) = CStr(rngGas.Range("A" & i + 1).Value)
        ' Get values.
        thisarray(i, 2) = Format(rngGas.Range(col & i + 1).Value, "##.##")
        frmChart.prgArrays.Value = i
    Next i

End Sub

Show quoteHide quote
"Kate" wrote:

> R1C1 is already off.
> Yes, I'm trying to create a chart.  Sorry that I didn't state it clearly.
>
> For example, the chart type is xlColumnClustered. The range of y-axis is
> colB, colC, and colD, from row1 to rowVariable. The range of x-axis is colA,
> from row1 to rowVariable.  How to create a chart like that?
>
> Now, I use:
> xlCht1.ChartType = xlColumnClustered
> xlCht1.SeriesCollection(1).XValues = xlWshtS.Range("B1:B" & rowVariable)
> The chart looks fine, except that the value of x-axis is missing.
>
> Thanks
> Kate
>
> "Kevan Hughes" wrote:
>
> > In Excel use TOOLS, OPTIONS then General.. Settings show R1C1.. uncheck the
> > box.. I gather you want to create a graph ?
> >
>
Author
26 May 2005 2:39 AM
Kate
Kevan,
I think it would be useful, but I don't have the SAMPLES folder...
Would you attach the MODCHART.BAS to me?
Thanks,
Kate

Show quoteHide quote
"Kevan Hughes" wrote:

> Kate, take a look at a sample.. You be missing a string declaration. Sample
> is loaded when installing VB locally..  should be \VB98\SAMPLES\VB98\CHRSAMP
> folder. The MODCHART.BAS is the code you should look at, DATE VALUES are used
> for x-axis labels/values.. IS this useful ?
>
> Public Sub PopOneArray(thisarray As Variant, col As String)
>     ' This procedure just populates arrays.
>     Dim i As Integer
>     ReDim thisarray(1 To intRows, 1 To 2)
>     For i = 1 To intRows
>         ' Get the Date values.
>         thisarray(i, 1) = CStr(rngGas.Range("A" & i + 1).Value)
>         ' Get values.
>         thisarray(i, 2) = Format(rngGas.Range(col & i + 1).Value, "##.##")
>         frmChart.prgArrays.Value = i
>     Next i
>
> End Sub
Author
27 May 2005 1:29 PM
Kevan Hughes
kevanhug***@hotmail.com

I can send the all the files to you if you email me above.. It is useful to
see the complete application in action..

Show quoteHide quote
"Kate" wrote:

> Kevan,
> I think it would be useful, but I don't have the SAMPLES folder...
> Would you attach the MODCHART.BAS to me?
> Thanks,
> Kate
>
> "Kevan Hughes" wrote:
>
> > Kate, take a look at a sample.. You be missing a string declaration. Sample
> > is loaded when installing VB locally..  should be \VB98\SAMPLES\VB98\CHRSAMP
> > folder. The MODCHART.BAS is the code you should look at, DATE VALUES are used
> > for x-axis labels/values.. IS this useful ?
> >
> > Public Sub PopOneArray(thisarray As Variant, col As String)
> >     ' This procedure just populates arrays.
> >     Dim i As Integer
> >     ReDim thisarray(1 To intRows, 1 To 2)
> >     For i = 1 To intRows
> >         ' Get the Date values.
> >         thisarray(i, 1) = CStr(rngGas.Range("A" & i + 1).Value)
> >         ' Get values.
> >         thisarray(i, 2) = Format(rngGas.Range(col & i + 1).Value, "##.##")
> >         frmChart.prgArrays.Value = i
> >     Next i
> >
> > End Sub
>