FYI - Issue With Clearing References to Variables RRS feed

  • Question

  • This issue is with Excel 365 (also appears to happen on Excel 2010).  I have an addin that creates a few tables and a few charts.  I move the charts to their own sheet.  I have to make charts and tables to specific dimensions.  I got all of it working stepping through code.  I always set all objects to nothing when they are no longer needed.  I avoid using global objects.  Some Subs have 30 or more variables with some being user defined types, chartobjects, charts and scripting dictionaries.  When I assembled and ran everything together I got weird results on the charts especially chart placement.  When I breakpoint between charts it works perfectly.  After a few days of debugging it appears some references aren't being cleared fast enough.  I was finally able to get it to work by adding a loop to delay and allow time to process pending events. I'm thinking it might be the user defined types.

        For k = 1 To 20000
        Next k

    So, if you experience issues where you step through code and it works but when you run it and you have issues it might be a reference clearing issue.

    • Edited by mogulman52 Friday, November 27, 2020 1:42 PM
    Thursday, November 26, 2020 3:19 PM