+ Reply to Thread
Results 1 to 2 of 2

UDF Not Updating When Data Changes

Hybrid View

  1. #1
    Registered User
    Join Date
    07-27-2010
    Location
    Cornwall England
    MS-Off Ver
    Excel 2007
    Posts
    1

    Angry UDF Not Updating When Data Changes

    Hi, I’m using Excel 2007 and I have a UDF which calculates the total of the largest x number of values in a range.
    I.e. in the range 1 2 3 4 5 6 7 8 9 10 where x is 2 the result would be 19 (9 + 10).

    The function works but does not update (or more accurately throws a #VALUE error) when either the range value or value of x is changed - if I force a recalculation the values update correctly.

    My code is as follows:

    valrange is the range of values from which I wish to extract the largest values
    discs is the number of relevant values (x in my example)


    Public Function Discards(valrange As Range, discs As Integer) As Double
    
    Application.Volatile
    Discards = 0
    
    Do While discs > 0
    Discards = Discards + Application.Large(Range(valrange.Address), discs)
    discs = discs - 1
    Loop
    
    End Function
    I'd really appreciate any suggestions as to how I can make this recalculate automatically!
    Thanks

    Quote Originally Posted by shg View Post
    Welcome to the forum.

    Please take a few minutes to read the forum rules, and then edit your post to amend the thread title accordingly and add CODE tags.

    Thanks.
    All done, sorry about that!
    Last edited by 44ron; 07-28-2010 at 05:17 AM. Reason: Request by Mod.

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: UDF Problem

    Welcome to the forum.

    Please take a few minutes to read the forum rules, and then edit your post to amend the thread title accordingly and add CODE tags.

    Thanks.
    Entia non sunt multiplicanda sine necessitate

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

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