+ Reply to Thread
Results 1 to 3 of 3

Getting Trendline formulae - results OK when stepping thru code, missing when running

  1. #1
    Registered User
    Join Date
    01-18-2013
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    1

    Getting Trendline formulae - results OK when stepping thru code, missing when running

    Hi Everyone

    I've got a bit of a weird problem - I've written some code to extract a trendline formula from a newly created graph and it works perfectly if, and only if, I step through it line by line. If I run the code it will sometimes return a null string instead of the formula - this is really annoying as I need to get the trendline formula from over 200 graphs in 200 files (that bit worked out with help from these forums).

    During my troubleshooting, I've simplified and simplified the code in terms of functions being called and subroutines etc but even with just the below, it's still really flakey.

    What I have is:

    Please Login or Register  to view this content.
    The graphs always get added, even if the formulas don't.
    The headings in G2 and G3 always get added, even if the formulas don't.
    I've tried outputting to a variable, instead of a cell value, and that doesn't always work.
    I've tried outputting to a msgbox, instead of a cell value, and that doesn't always work.

    The draw_a_graph sub-routine is called from

    Please Login or Register  to view this content.
    I have uploaded 5 of the files to be graphed reports.zip.

    I'm running Excel 2010 on Windows 7.

    I've searched all sorts of forums and help files and google and I just can't make heads or tails of what's happening - any thoughts gratefully accepted!

    All the best

    David

  2. #2
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: Getting Trendline formulae - results OK when stepping thru code, missing when running

    hi David, welcome to Excelforum, may be that is not the best ever solution to your problem but it works for me and gives result you want. Change the original code block:

    Please Login or Register  to view this content.
    to

    Please Login or Register  to view this content.

  3. #3
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Getting Trendline formulae - results OK when stepping thru code, missing when running

    You could instead use LINEST to get the trendline coefficients, rather than copy them from the limited precision shown in the trendline label.
    Entia non sunt multiplicanda sine necessitate

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1