help with chart

A

A Whelan

hi i can create a chart with one set of data from range a1 to a10 using the
below code
can someone please advise me how to add a second set of data to the the
chart i.e so the full data range woul be from a1 to b10


Public Sub cSheet()
Dim dataRange As Range
Set dataRange = Range("A2:a10")

Charts.Add
With ActiveChart
.HasTitle = True
.ChartTitle.Characters.Text = "hello"
.ChartType = xlColumnClustered
.HasLegend = True
.Legend.Position = xlRight
.Axes(xlCategory).MinorTickMark = xlOutside
.Axes(xlValue).MinorTickMark = xlOutside
.Axes(xlValue).MaximumScale =
Application.WorksheetFunction.RoundUp(Application.WorksheetFunction.Max(dataRange),
-1)
.Axes(xlCategory).HasTitle = True
.Axes(xlCategory).AxisTitle.Characters.Text = "Harry"
.Axes(xlValue).HasTitle = True
.Axes(xlValue).AxisTitle.Characters.Text = "Andy"
.SeriesCollection(1).Name = "Sample Data"
.SeriesCollection(1).Values = dataRange

End With
End Sub
 
K

keri

You can change the line below;

Set dataRange = Range("A2:a10")
to
Set dataRange = Range("A2:B10")

If you want to do this in a seperate series post back and i'll give you
some more code.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top