Selasa, 21 Februari 2012

Re: [ExcelVBA] Problem with charts

 

You appear to be creating new series from within the loop. I suspect that
this creates lots of new series. You presumably want to create only one new
series - outside the loop.

If you want to give the chart a pair of disjoint ranges (and I'm not even
sure you can do that), then you'll need to create the ranges as you go,
inside the loop, then pass them to a single "new series" call. You might
find it easier to keep the ranges as text strings while you build them up.

Regards, Dave S

----- Original Message -----
From: "jasarmiento" <jasarmiento@yahoo.com>
To: <ExcelVBA@yahoogroups.com>
Sent: Wednesday, February 22, 2012 3:05 AM
Subject: [ExcelVBA] Problem with charts

> Hi all,
>
> I'm trying to add series to a chart while there is any text info in Column
> A (titles) and there is any value in Column E.
> It is a simple barchart with some values in Y-Axis (column E) and the
> series titles as X-axis (column is A). I created a loop but the chart
> doesn't show all titles in X-axis. X-axis only shows the first name. Can
> anybody help me?
>
> I'm attaching the code:
>
> Sub AddNewSeries()
>
> Dim f1 As Integer
> Dim FacVal As Range
> Dim FacName As Range
>
> ActiveSheet.Shapes("faculty").Select
>
> Range("A20").Select
> Set FacName = ActiveCell
> Do While Len(FacName) > 1
> ActiveCell.Offset(0, 4).Range("A1").Select
> f1 = ActiveCell
> If f1 > 0 Then
> Set FacVal = ActiveCell
> ActiveSheet.Shapes("faculty").Select
> With ActiveChart.SeriesCollection.NewSeries
> .Name = FacName
> .XValues = FacName
> .Values = FacVal
> ActiveCell.Offset(1, -4).Range("A1").Select
> Set FacName = ActiveCell
> End With
> Else
> ActiveCell.Offset(1, -4).Range("A1").Select
> Set FacName = ActiveCell
> End If
> Loop
>
> End Sub
>
>
> Thank you.
>
>
>
> ------------------------------------
>
> ----------------------------------
> Be sure to check out TechTrax Ezine for many, free Excel VBA articles! Go
> here: http://www.mousetrax.com/techtrax to enter the ezine, then search
> the ARCHIVES for EXCEL VBA.
>
> ----------------------------------
> Visit our ExcelVBA group home page for more info and support files:
> http://groups.yahoo.com/group/ExcelVBA
>
> ----------------------------------
> More free tutorials and resources available at:
> http://www.mousetrax.com
>
> ----------------------------------Yahoo! Groups Links
>
>
>
>
>
> -----
> No virus found in this message.
> Checked by AVG - www.avg.com
> Version: 10.0.1424 / Virus Database: 2112/4821 - Release Date: 02/20/12
>

__._,_.___
Recent Activity:
----------------------------------
Be sure to check out TechTrax Ezine for many, free Excel VBA articles! Go here: http://www.mousetrax.com/techtrax to enter the ezine, then search the ARCHIVES for EXCEL VBA.

----------------------------------
Visit our ExcelVBA group home page for more info and support files:
http://groups.yahoo.com/group/ExcelVBA

----------------------------------
More free tutorials and resources available at:
http://www.mousetrax.com

----------------------------------
.

__,_._,___

Tidak ada komentar:

Posting Komentar