Basic Charting data selection

  • Thread starter Thread starter mitreviper
  • Start date Start date
M

mitreviper

Hi all,
I'm new to VBA excel. I need to plot a graph such that column A
data are x values with relation to colunm B data (y-axis)

How can i do this ? Thank you all in advance


oSheet3.Range("A1").Resize(51, 1).Value = ChartXDataArray
oSheet3.Range("B1").Resize(51, 1).Value = ChartYDataArray

Dim ch As Object
Dim chart1 As Object
Set ch = oSheet3.ChartObjects.Add(100, 30, 350, 270)
Set chart1 = ch.Chart
' chart1.Name = "NAme"

chart1.ChartType = xlColumnStacked
chart1.SetSourceData Source:=oSheet3.Range("B1:B51"), _
PlotBy:=xlColumns
chart1.SetSourceData Source:=oSheet3.Range("A1:A51"), _
PlotBy:=ylColumns
chart1.HasLegend = False
 
Here's some beginning VBA for Excel charts:

http://peltiertech.com/Excel/ChartsHowTo/QuickChartVBA.html

This might be what you're trying to do:

Dim ch As ChartObject
Dim chart1 As Chart
Dim srs As Series
Set ch = oSheet3.ChartObjects.Add(100, 30, 350, 270)
ch.Name = "Name"
Set chart1 = ch.Chart
chart1.ChartType = xlColumnStacked
Set srs = chart1.SeriesCollection.NewSeries
With srs
.Values = oSheet3.Range("B1:B51")
.XValues = oSheet3.Range("A1:A51")
End With

- Jon
 
Back
Top