Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to output equation from a graph in excel 1

Status
Not open for further replies.

litho

Technical User
Jul 11, 2001
11
US
Hi

When you have created a graph in excel, you can add a polynominal trendline to it and display the equation on the graph. This equation is of the form ax^2+bX+C. What I need is to have the A, B and C in cells in the spreadsheet so that I can further manipulate them.

This can be done for a linear line using the functions slope, intercept, but how can you do it for a polynominal..

Thanks

Steve

 
Give this a try :
Note : will write equation as text into cell A1.

Sub GetChartFormula()
ActiveSheet.ChartObjects("Chart 1").Activate
ActiveSheet.Rows(1).Columns(1) = ActiveChart.SeriesCollection(2).Trendlines(1).DataLabel.Text
Range("A1").Select
End Sub

Now write the following equations in A2, A3, A4 to obtain the parameters.
A2
=VALUE((MID(A$1,FIND("=",A$1)+2,FIND("x2",A$1)-FIND("=",A$1)-2)))
A3
=VALUE((MID(A$1,FIND("x2",A$1)+5,FIND("x ",A$1)-FIND("x2",A$1)-5)))
A4
=VALUE((MID(A$1,FIND("x ",A$1)+4,20)))

I know I'm being brief, and I hope your file is not too complicated, but I think you can take it from there. If not, I'll explain in more detail.
 
Hi
Thanks for the help. I am a fairly novice macro user and am having difficuly getting the macro part to work. Have you put in all the macro or is more required to get the equation output into the cell..??

It seems as if it is copying the equation OK, but maybe there is no paste command to output it.

Or it may be something completely different

Thanks

Steve
 
I'm going to make a guess on this - the file I worked with only had 1 chart. Note the ChartObjects("Chart 1")

To find out what yours may be, right-click on chart, select ChartWindow. The window header will display the Chart #, then change the macro accordingly.

See if that works.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top