+ Reply to Thread
Results 1 to 6 of 6

Why is a custom function running when it is not called.

  1. #1
    Forum Contributor
    Join Date
    02-16-2012
    Location
    London, England
    MS-Off Ver
    Excel mac 2011
    Posts
    238

    Why is a custom function running when it is not called.

    Just a curious one here, I am trying to write what has turned into (for me) a very complex macro. I have the macro run through various subroutines. But this particular sheet also has a custom function that I wrote that is used within the spreadsheet to do a calculation, and this function is not called upon for this particular macro, yet at a certain point in the code it runs.

    Is it because it is used as a formula within the sheet that it runs, or am I doing something wrong?

    Kind regards

    Rob

  2. #2
    Forum Contributor HaroonSid's Avatar
    Join Date
    02-28-2014
    Location
    india
    MS-Off Ver
    Excel 2013
    Posts
    2,095

    Re: Why is a custom function running when it is not called.

    Upload Sample
    Use Code-Tags for showing your code :
    Please mark your question Solved if there has been offered a solution that works fine for you
    If You like solutions provided by anyone, feel free to add reputation using STAR *

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

    Re: Why is a custom function running when it is not called.

    You're not doing anything wrong - this is normal behaviour.
    Everyone who confuses correlation and causation ends up dead.

  4. #4
    Forum Contributor
    Join Date
    02-16-2012
    Location
    London, England
    MS-Off Ver
    Excel mac 2011
    Posts
    238

    Re: Why is a custom function running when it is not called.

    Ok, here is the main Macro:
    Please Login or Register  to view this content.
    And here is the Function in a different module:
    Please Login or Register  to view this content.

  5. #5
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Why is a custom function running when it is not called.

    Quote Originally Posted by Rob K View Post

    Is it because it is used as a formula within the sheet that it runs, or am I doing something wrong?

    Kind regards

    Rob
    It will run if a cell that is referenced by the formula, either directly or indirectly, is changed.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  6. #6
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,644
    If at any point a sheet that has the function on it is calculated the function could be called.

    So something in your main code must be triggering calculation.

    If you don't want that to happen you could set calculation to manual at the start of the code.
    Please Login or Register  to view this content.
    If posting code please use code tags, see here.

+ 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. Replies: 0
    Last Post: 02-21-2013, 08:28 AM
  2. Replies: 0
    Last Post: 05-23-2007, 08:05 PM
  3. [SOLVED] How to make userform disappear while called subroutine is running
    By Cornelia in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-16-2006, 05:50 PM
  4. Need to know what cell called the custom VBA function?
    By partyOfOne in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-19-2005, 01:05 PM
  5. [SOLVED] Custom Function being called when it shouldn't.
    By Ron in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-18-2005, 04:06 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