View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.charting
Faye
 
Posts: n/a
Default How to put these two together?

I have a spreadsheet that I want to produce charts from. I know how to
find the addresses of ranges that I want to produce charts for. And I
have the codes to create a chart for one data range in the spreadsheet.
Now, how do I tie them together so that the charts will be created by
one macro?

Addresses of ranges to chart
===============================
Set rStart = Range("A1")
grp = rStart.Value

i = 2
Do While Cells(i - 1, 1) < ""
If Cells(i, 1) < grp Then
Set rng = Range("B1", Cells(i - 1, 4))
MsgBox " Addresses for graphing a " & rng.Address(0, 0)

Set rStart = Cells(i, 1)
grp = rStart.Value
End If
i = i + 1
Sheets("Chart").Select
Loop


Macro for the chart
==============
Charts.Add
ActiveChart.ChartType = xlLineMarkers
ActiveChart.SetSourceData
Source:=Sheets("Chart").Range(B2:D4), PlotBy:=xlColumns

ActiveChart.SeriesCollection(1).ChartType = xlColumnClustered
ActiveChart.SeriesCollection(1).Name = "=""Maximum"""
ActiveChart.SeriesCollection(2).Name = "=""95th"""
ActiveChart.SeriesCollection(3).Name = "=""5th"""
ActiveChart.SeriesCollection(2).Points(1).ApplyDat aLabels
ShowValue:=True
ActiveChart.SeriesCollection(3).Points(1).ApplyDat aLabels
ShowValue:=True

With ActiveChart
.HasTitle = True
.ChartTitle.Characters.Text = "Employee Survey"
.Axes(xlCategory, xlPrimary).HasTitle = False
.Axes(xlValue, xlPrimary).HasTitle = False
End With

Thanks in advance.

Faye Larson