+ Reply to Thread
Results 1 to 2 of 2

Macro fails to Record String Results, Step Through Works

  1. #1
    Forum Contributor
    Join Date
    07-01-2018
    Location
    Adelaide, South Australia
    MS-Off Ver
    Office 365, & Excel 2016 on windows 10, & 14.7 for mac, & Excel 2015 for mac
    Posts
    173

    Macro fails to Record String Results, Step Through Works

    I have a table of timed data points for solar power generation. I want to be able to select a data range (ie all data in one month), generate a trendline, and record the the trendline formula in a table.

    Sheet7 is a large table of data, with columns "P", and "W" of interest for now.
    Sheet13 is where I am trying to record my table of trends for comparison.

    To that end I made this macro. It
    -makes a table of unique year/month combinations in sheet 13
    -loops through each item in the table and generates a range object including the data for that month
    -charts the data and extracts the trendline formula
    -records the formula in the table in sheet13

    The problem is the macro returns blank strings if it is allowed to run like normal. But if I step through in debug mode, the results are recorded as expected.

    the problem seems the string assignments in "getTrend()"

    Please Login or Register  to view this content.
    I got through my one year of data by hitting F8 between strategically placed code breaks, but this will be a major pain when I need to run multiple years of data. Any advice on fixing this would be greatly appreciated.


    Here is my code in entirety
    File with some example data is attached. All other columns were cleared to get it under 1000kB limit.
    Please Login or Register  to view this content.
    Attached Files Attached Files

  2. #2
    Forum Contributor
    Join Date
    07-01-2018
    Location
    Adelaide, South Australia
    MS-Off Ver
    Office 365, & Excel 2016 on windows 10, & 14.7 for mac, & Excel 2015 for mac
    Posts
    173

    Re: Macro fails to Record String Results, Step Through Works

    I have solved my problem by finding out how to avoid the charts and strings entirely, using the LinEst Function

    I replaced the "GetTrend" with the following.

    Please Login or Register  to view this content.
    Why do I always do it the hard way first?

    That said, I would still appreciate feedback on what was failing in my first macro, so that I can avoid making the same mistake again.
    Regards Truk2

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Macro errors when running, but works when done step by step
    By taylorsm in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-02-2018, 03:54 PM
  2. VBA Code works by step by step, doesn't work by running
    By lucasar in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-24-2016, 06:33 AM
  3. Macro works during Step Into but not when fully run
    By LLL0422 in forum Excel Programming / VBA / Macros
    Replies: 45
    Last Post: 06-06-2014, 04:57 AM
  4. [SOLVED] Macro works in step through but not when run
    By bruizer31 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-01-2013, 05:50 PM
  5. Macro run fails, step through works.
    By SteveAlston in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-15-2009, 11:37 PM
  6. Macro Works but not in Debug Step mode
    By Bob Smedley in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-31-2006, 12:35 PM
  7. [SOLVED] macro works differently when using the Step Into (F8) feature
    By Dave Y in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-23-2005, 11:05 PM

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