+ Reply to Thread
Results 1 to 7 of 7

Function/sub exiting early except when called from Developer tab

  1. #1
    Registered User
    Join Date
    04-05-2017
    Location
    Houston, TX
    MS-Off Ver
    2016
    Posts
    57

    Function/sub exiting early except when called from Developer tab

    I have a sub that performs a variety of actions such as taking inputs from a worksheet and outputting to another as well as modifying a chart object. I want the sub to be "volatile" so that it evaluates whenever any changes are made to the workbook. I've tried to make it both a Function and a Sub that is called by a separate volatile function but the end result is the same. For some reason the sub appears to exit early unless I call it from the Developer tab and not when a change is made on a worksheet however I don't want to do that since I want the evaluation to be automatic.

    I've attached a simplified version of the workbook and the "exiting early" issue can easily be seen if breaks are placed on the three lines that output to the "K" worksheet.

    As a second issue, the breaks also show that the sub evaluation isn't straight through and is bouncing from one line to another for some reason.
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    04-01-2013
    Location
    East Auckland
    MS-Off Ver
    Excel 365
    Posts
    1,343

    Re: Function/sub exiting early except when called from Developer tab

    maybe turn off events and calculation to avoid it looping by constantly calling itself?
    see if it helps.

    Please Login or Register  to view this content.
    If you want something done right... find a forum and ask an online expert.

    Time flies like an arrow. Fruit flies like a banana.

  3. #3
    Registered User
    Join Date
    04-05-2017
    Location
    Houston, TX
    MS-Off Ver
    2016
    Posts
    57

    Re: Function/sub exiting early except when called from Developer tab

    I'm still getting the same result after adding the extra few lines. Still seems to be jumping around a lot and the plotK sub isn't automatically producing the outputs that I'm looking for.

    Ideally I would be able to get rid of the function that is calling the plotK sub but if there isn't another way to get the intended result then that would be acceptable as well.

  4. #4
    Registered User
    Join Date
    04-05-2017
    Location
    Houston, TX
    MS-Off Ver
    2016
    Posts
    57

    Re: Function/sub exiting early except when called from Developer tab

    Here is the original code if someone happens to pass by the post and doesn't want to download the attachment.

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.

  5. #5
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,358

    Re: Function/sub exiting early except when called from Developer tab

    A function called from a cell cannot modify the value of other cells, even if you try to do it indirectly by having it call a different subroutine. If you want it to happen whenever any changes are made to the workbook, use the Workbook_SheetChange event in the ThisWorkbook module to call the sub.
    Everyone who confuses correlation and causation ends up dead.

  6. #6
    Registered User
    Join Date
    04-05-2017
    Location
    Houston, TX
    MS-Off Ver
    2016
    Posts
    57

    Re: Function/sub exiting early except when called from Developer tab

    Thanks, I didn't know this before. I have it doing what I want now with the Workbook_SheetChange event.

  7. #7
    Registered User
    Join Date
    10-05-2019
    Location
    Work: East Coast; Home: Texas, USA
    MS-Off Ver
    Mostly 2010 ( Windows 10 & 365 Insider Super Fast )
    Posts
    32

    Re: Function/sub exiting early except when called from Developer tab

    pp57,
    More of a curiosity answer, a UDF placed in a cell, which will modify the values of other cells , along the lines of what you tried to do in your original coding.
    Please Login or Register  to view this content.
    Type , for example, something in the first cell, and usually some cells will be modified along the lines of what you tried to do in your original coding
    Molly
    Attached Files Attached Files
    Last edited by MollyBrennholz; 01-23-2020 at 07:48 PM.

+ 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. Developer List Box indirect function
    By Martines91 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 04-18-2019, 03:15 AM
  2. Replies: 7
    Last Post: 06-09-2017, 08:54 AM
  3. EXCEL VBA runtime error 1004 exiting function
    By pandale in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-25-2015, 08:49 PM
  4. [SOLVED] VBA - Insert a IF function within an exiting coding.
    By Boubou009 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-10-2014, 09:16 PM
  5. early excel, loss of function
    By taffocon in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 03-26-2013, 09:31 AM
  6. Date Function giving dates from early 1900s
    By nhrav in forum Excel General
    Replies: 4
    Last Post: 07-25-2008, 02:03 PM
  7. Exiting called macro on error, then ending macro caller.
    By Yappa in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-13-2008, 10:28 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