Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default Expand Chart Macro to Plot Multiple Series

Gang - Andy Pope graciously provided the following Macro that will very
nicely generate 88 charts. It plots a single y value for each x. I
would like to expand that and plot 2 or perhaps 3 y values (i.e., 3
series rather than just 1) for each x. Could someone please help me
figure out how to do this? I've made a few changes to the code with no
luck.

Also would someone confirm the following - trying to generate nonpivot
charts from a pivot table can't be done. The data that I'm trying to
plot is in a Pivot table. I found that the only way to make the thing
work is to get the data out of the pivot table. Is that accurate?

Hi,

This should get you started. I would try it on a subset of the data
first rather than all 88 sets. You will still need to add any
formatting
code you have recorded.


Sub Macro1()
'
' Macro1 Macro
' Macro recorded 05/07/2006 by Andy Pope
'
Dim lngRow As Long
Dim lngStartRow As Long
Dim chtDeer As Chart
Dim shtData As Worksheet
Dim rngXData As Range
Dim rngYData As Range
Dim strCounty As String


'
Set shtData = Worksheets("Sheet1")
lngRow = 2
lngStartRow = 2
Do While shtData.Cells(lngRow, 1) < ""
If shtData.Cells(lngRow, 1) < shtData.Cells(lngRow + 1, 1)
Then
Set rngXData = shtData.Range( _
"B" & lngStartRow & ":B" & lngRow)
Set rngYData = rngXData.Offset(0, 1)
strCounty = shtData.Cells(lngRow, 1).Value
' make a chart
Set chtDeer = Charts.Add
With chtDeer
Do While .SeriesCollection.Count 0
.SeriesCollection(1).Delete
Loop
.ChartType = xlXYScatterLines
.PlotBy = xlColumns
With .SeriesCollection.NewSeries
.XValues = rngXData
.Values = rngYData
End With
.Location Whe=xlLocationAsNewSheet
.HasTitle = True
.ChartTitle.Characters.Text = strCounty
.Axes(xlCategory, xlPrimary).HasTitle = False
.Axes(xlValue, xlPrimary).HasTitle = False
.HasLegend = False
.Name = strCounty
End With
lngStartRow = lngRow + 1
End If
lngRow = lngRow + 1
Loop


Set rngXData = Nothing
Set rngYData = Nothing
Set shtData = Nothing
Set chtDeer = Nothing


End Sub

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 to plot column chart with one series against multiple series. svenkateshmurthy Charts and Charting in Excel 2 October 16th 07 09:09 PM
Use a macro to expand data series for chart? Kevin Clark Charts and Charting in Excel 0 June 21st 06 07:31 PM
plot multiple time series Moohwan Charts and Charting in Excel 1 April 27th 06 12:36 PM
chart data series -- plot a table as a single series hjc Charts and Charting in Excel 7 September 20th 05 05:52 PM
Why plot area does not expand after clearing series legend? [email protected] Charts and Charting in Excel 6 July 25th 05 01:00 AM


All times are GMT +1. The time now is 12:16 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"