PDA

View Full Version : Sleeper: Scatter Plot with VBA



gstein1231
09-15-2008, 03:07 PM
I am trying to take data off of a worksheet and create a scatter plot with lines and no markers in the same worksheets using vba.

The x values are in a2:a6 and the y-values are in b2:b6. The title could be something generic like chart 1 and the axes could be labeled x and y. I am having the most trouble figuring how to get the y-values to plot with the x-values instead of excel making two seperate lines on the chart. Please help!

Bob Phillips
09-15-2008, 03:31 PM
Charts.Add
With ActiveChart
.ChartType = xlXYScatter
.SetSourceData Source:=Sheets("Sheet3").Range("A1:B6")
.PlotArea.ClearFormats
.Axes(xlValue).MajorGridlines.Border.ColorIndex = 15
.ChartTitle.Delete
.Legend.Delete
.ChartType = xlLineMarkers
.Location Where:=xlLocationAsObject, Name:="Sheet3"
End With