+ Reply to Thread
Results 1 to 7 of 7

VBA code called from cell, permanently triggered by Excel???

  1. #1
    Forum Contributor
    Join Date
    04-05-2011
    Location
    behind you!
    MS-Off Ver
    Excel 2010
    Posts
    116

    VBA code called from cell, permanently triggered by Excel???

    Please Login or Register  to view this content.
    Hi,

    I wrote this simple code. Its meaning is

    1) to count every value change in a 1dim-range
    2) or, to count every change in a 1dim-range, on a specific value (filterVal)

    The code works as expected if calculation mode is manual. However, by switching to calculation mode automatic, Excel calls permanently the function.
    By setting a breakpoint anythere in the code, the debugger immediately stops there.

    I have no clue why this happens. Any ideas?

    Lloyd

  2. #2
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,016

    Re: VBA code called from cell, permanently triggered by Excel???

    Surely if the calculation mode is manual, the code shouldn't work at all?
    Everyone who confuses correlation and causation ends up dead.

  3. #3
    Forum Contributor
    Join Date
    04-05-2011
    Location
    behind you!
    MS-Off Ver
    Excel 2010
    Posts
    116

    Re: VBA code called from cell, permanently triggered by Excel???

    Nope, of course triggered the code by calling the formula from cell level. The code works as expected if calculation mode is manual.

  4. #4
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,016

    Re: VBA code called from cell, permanently triggered by Excel???

    If calculation is manual, the code should only run when you first enter the formula. If it's automatic, the code will be called whenever you change any of the inputs - either the filterval, or any cell within the input range. Switching from manual to automatic will also cause the code to run if the cell(s) using the function have been flagged as dirty.

  5. #5
    Forum Contributor
    Join Date
    04-05-2011
    Location
    behind you!
    MS-Off Ver
    Excel 2010
    Posts
    116

    Re: VBA code called from cell, permanently triggered by Excel???

    the code will be called whenever you change any of the inputs - either the filterval, or any cell within the input range

    Thx. That's it! I underestimated the consumption of resources of this code.

    Is there a way to suppress the recalculation for a specified cell/range?

  6. #6
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,016

    Re: VBA code called from cell, permanently triggered by Excel???

    If you don't want it as a live function, I suggest you use a subroutine to populate the required values as and when needed. Alternatively, you could use a flag cell that controls whether to call your function or not - i.e. something like:

    =IF(A1=1,yourfunction(),"")

    and then simply switch A1 to 1 when you want the calculation to happen.

  7. #7
    Forum Contributor
    Join Date
    04-05-2011
    Location
    behind you!
    MS-Off Ver
    Excel 2010
    Posts
    116

    Re: VBA code called from cell, permanently triggered by Excel???

    Good idea, thx!!!

+ 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. VB Drop down menu Code in module called from multiple Excel Sheets
    By kawi6rr in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 09-20-2018, 03:05 PM
  2. [SOLVED] Why does code called from a macro button to write data to an excel table work correctly, b
    By mgeoyoung in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-27-2017, 08:57 PM
  3. Any code to permanently group two spreadsheets?
    By rramoutar7 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 09-24-2014, 03:20 PM
  4. How to write a code so that a macro called "Mega" runs only once if cell value A1 > 0
    By omega0010 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-31-2014, 10:47 AM
  5. Set a delay in VB script after called excel macro code
    By Jovillanueva in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-29-2014, 10:09 AM
  6. [SOLVED] how to trace through VC++6.0 code which is called from Excel 2003 VBA
    By venkateshpitta@gmail.com in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-06-2006, 06:45 AM
  7. [SOLVED] Code not getting triggered by change in value
    By Baapi in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-15-2006, 02:20 AM

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