+ Reply to Thread
Results 1 to 4 of 4

Function firing alone randomly

  1. #1
    Registered User
    Join Date
    09-05-2014
    Location
    Montreal
    MS-Off Ver
    2007
    Posts
    22

    Function firing alone randomly

    Hi all,
    I have created a function returning a date with two arguments: two numbers that come from cells within the same workbook. When any event-type change occurs in any sheet (for instance deleting/copying range, changing the value of a range), the function fires alone with the two last given arguments. Moreover when the compiler gets the the the "End Function" line, it fires the same function over for about 5-10 times. I tried to set application.enableevents=false as a test and it worked. When I set it back to =true again, the function wasn't firing alone.. until the workbook is re-opened. Does anyone have a clue about what could be the explanation?

    Thanks,

  2. #2
    Forum Expert
    Join Date
    10-09-2014
    Location
    Newcastle, England
    MS-Off Ver
    2003 & 2013
    Posts
    1,986

    Re: Function firing alone randomly

    When you say "any event-type change occurs" what exactly do you mean?

    If you're firing the function on any data changing then Im assuming your function then changes a cell itself which in turn will then trigger the function again....etc etc
    If someone has helped you then please add to their Reputation

  3. #3
    Registered User
    Join Date
    09-05-2014
    Location
    Montreal
    MS-Off Ver
    2007
    Posts
    22

    Re: Function firing alone randomly

    Thanks for replying so quickly,
    Actually no, the function returns a date value used only in the VBA code. I have noticed the function fires when any of the changes mentioned above occurs and I think it is event related since disabling events prevent that. For instance, the latest event I have tested is closing the workbook, even though I have no code for that event, the function is triggered.

  4. #4
    Registered User
    Join Date
    09-05-2014
    Location
    Montreal
    MS-Off Ver
    2007
    Posts
    22

    Re: Function firing alone randomly

    Ok I got it, someone put the UDF in a couple of cells in the workbook. The UDF is therefore triggered by any change, look up UDF calculation sequence in google. As for the workbook_close() event, it resets the value of a particular cell, hence the function is triggered.

+ 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. Function inside a button to randomly generate number?
    By fkalinx in forum Excel General
    Replies: 2
    Last Post: 09-16-2014, 03:31 PM
  2. Public Function won't stop firing
    By carsto in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-18-2014, 08:20 PM
  3. [SOLVED] Custom function not firing when a change to the workbook/worksheet has been done
    By thechazm in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 04-16-2013, 10:20 AM
  4. Datalabel.Text randomly returns empty strings in a recursive function
    By Miragel in forum Excel Charting & Pivots
    Replies: 0
    Last Post: 10-17-2012, 06:17 PM
  5. IF function randomly skips rows - why?
    By Heirak in forum Excel General
    Replies: 3
    Last Post: 03-05-2012, 08:09 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