Solved

Extract equation parameters from chart

Posted on 2014-01-07
3
405 Views
Last Modified: 2014-01-07
Hello,

The attached worksheet contains a script (CreateCharts) that outputs a series of line charts and scatter charts (based on a range of input data) to a sheet named "Charts".

Each scatter chart on the "Charts" sheet contains an equation for a linear trendline.

The other script (SlopeTable) contained within this workbook is designed to read each chart and extract the chart title and slope of the trendline from the equation on the chart.

I am in need of an amendment to the SlopeTable script  that will read the equation on only the scatter charts and write the chart title, slope, y-intercept, and R-squared values to a  table in the sheet named "Params_Table".

For an example, I have shown the desired results for the first scatter chart (labeled as BR1) in row 2 of the "Params_Table". I entered these values manually.

Many thanks in advance to anyone who may be able to add this functionality,
equation-parameters-to-table.xlsm
0
Comment
Question by:dougf1r
3 Comments
 
LVL 50

Accepted Solution

by:
Rgonzo1971 earned 500 total points
ID: 39762654
Hi,

pls try

Sub Findparameters()


RowIndex = 2

For Each ChtObj In Sheets("Charts").ChartObjects
    Set cht = ChtObj.Chart
    For Each SerCol In cht.SeriesCollection
        Set TrdLines = SerCol.Trendlines
        If TrdLines.Count > 0 Then
            Set TrdLn = TrdLines(1)
            strParameters = Replace(TrdLn.DataLabel.Text, Chr(10) & "R" & Chr(178), "")
            strParameters = Replace(strParameters, "x", "")
            aParameters = Split(strParameters, " ")
            Range("A" & RowIndex).Value = cht.ChartTitle.Text

            Range("B" & RowIndex).FormulaLocal = aParameters(2)
            Range("C" & RowIndex).FormulaLocal = aParameters(4)
            Range("D" & RowIndex).FormulaLocal = aParameters(6)
            RowIndex = RowIndex + 1
        End If


    Next
Next


End Sub

Open in new window

EDIT Now FormulaLocal

Regards
0
 
LVL 29

Expert Comment

by:gowflow
ID: 39762726
ok here it is

download the file make sure macros are activated and position yourself in any sheet and activate the macro called SlopeTable and check the results.

Rgds/gowflow
equation-parameters-to-table.xlsm
0
 
LVL 1

Author Comment

by:dougf1r
ID: 39762884
Many thanks for the responses.

Rgonzo1971 has the correct solution.

The response from gowflow causes the last four ID's to repeat the same value for each parameter. Not sure why this occurs? I do like the pop-up message window after execution.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Adding a countdown to HTA 12 91
Help to break down spreadsheet 3 37
Desktop in File-open on Excel 7 29
Excel Data Validation Help 9 40
Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.

680 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question