Not working yet. I have copied my current code below. The problems I am experiencing are these:
1) I'm pretty sure that the graph the this code is generating is adding to an existing graph, not starting a new one. It is also generating curves, not lines - but I'm pretty sure that this is connected.
2) I'm almost positive that when I write the graph to a file, (near the end of the code) it is not overwriting the previous file and not giving me a message about it.
Any and all ideas would be most helpful. I am pretty sure I have reached the limits of my ignorance. Note that I have left in (but commented out) the lines that were generated by the macro recorder but I am not using.
Gene, "The Mortgage Man", Klein
'Generate the Graph
'First create the 2 arrays, each holding 4 values per each of the 2 lines:
'Since we have y intercept, 0 is one x value and just use 10 for second x value
yval = 10 * slope1 + bint1
line1array = Array(0, 10, bint1, yval)
yval = 10 * slope2 + bint2
line2array = Array(0, 10, bint2, yval)
Charts.Add
ActiveChart.ChartType = xlXYScatterSmooth
'ActiveChart.SetSourceData Source:=Sheets("Sheet1").Range("B1:C2"), PlotBy:= _
' xlRows
'replacing above line with this line:
ActiveChart.SeriesCollection(1).Values = line1array
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(1).Name = "=""line1"""
'ActiveChart.SeriesCollection(2).XValues = "=Sheet1!R5C2:R5C3"
'ActiveChart.SeriesCollection(2).Values = "=Sheet1!R6C2:R6C3"
ActiveChart.SeriesCollection(2).Values = line2array
ActiveChart.SeriesCollection(2).Name = "=""line2"""
ActiveChart.Location Where:=xlLocationAsObject, Name:="Sheet1"
With ActiveChart
.HasTitle = False
.Axes(xlCategory, xlPrimary).HasTitle = False
.Axes(xlValue, xlPrimary).HasTitle = False
End With
'The following three lines taken from JW's Excel 2002 Power Programming with VBA page 464
Set CurrentChart = Sheets("Sheet1").ChartObjects(1).Chart
Fname = ThisWorkbook.Path & "\temp.gif"
CurrentChart.Export Filename:=Fname, Filtername:="GIF"
Image1.Picture = LoadPicture(Fname)
End Sub