+ Reply to Thread
Results 1 to 3 of 3

Get UDF to recalculate without making it volatile or troubleshooting if it is

  1. #1
    Registered User
    Join Date
    07-21-2015
    Location
    Durham, NC, US
    MS-Off Ver
    2010
    Posts
    2

    Get UDF to recalculate without making it volatile or troubleshooting if it is

    I hope I'm phrasing my problem adequately. I'm not a particularly experienced coder, and am really brand new to user defined functions, and this is my first time posting to this forum.

    So, I've got a workbook SampleSheet.xlsx and a handy dandy User Defined Function:

    Please Login or Register  to view this content.
    If the Application.Volatile line is not commented out, the function works great for the most part, and updates as I add and remove sheets whose names contain "CB" to my workbook and change the information in these sheets. Since different projects will require different numbers of consultant sheets that folks will want to rename to something meaningful, I'm not sure how to pass that information into my function arguments in a way that would force recalculation. Help with this would be ideal.

    But, I understand it is generally not a good idea to make UDFs volatile. Also, this brings me problems down the line. After I've done all my calculations, I also want to be able to do some data harvesting, by grabbing specific sheets from all workbooks in a folder and putting the values of the cells into worksheets in a new workbook. I've tried code that does paste special values and that just tries to set the values equal to one another (see code below, for privacy I put "..." instead of my network path in three places), and in either case the consultant billings column of my worksheet zeros out (unless it's not volatile). I can replicate this behavior manually without running all that code below by selecting all the cells in the worksheet, copying, and then trying to paste special --> values into a new worksheet twice in a row. It typically works on the first new worksheet, and then zeros out the consultant billings calculations on the second new worksheet.

    All help is appreciated. Thanks.

    -Beth


    Please Login or Register  to view this content.

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

    Re: Get UDF to recalculate without making it volatile or troubleshooting if it is

    Your issue is almost certainly the use of ActiveWorkbook in the UDF. I assume you want to refer to the workbook the function is in, in which case use ThisWorkbook instead. If however the code is in a separate workbook (eg an add-in) then you could refer to the workbook that contains the 'phase' range by using:
    Please Login or Register  to view this content.
    Everyone who confuses correlation and causation ends up dead.

  3. #3
    Registered User
    Join Date
    07-21-2015
    Location
    Durham, NC, US
    MS-Off Ver
    2010
    Posts
    2

    Re: Get UDF to recalculate without making it volatile or troubleshooting if it is

    Thank you so much! This solves the problem!

+ 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. Troubleshooting the 'if' function
    By mitchellkerr in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 07-28-2014, 10:39 AM
  2. [SOLVED] Troubleshooting a countif :-( Seriously
    By Scalpel4 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 05-01-2014, 11:39 AM
  3. [SOLVED] COUNTIFS Volatile or Non-Volatile?
    By sinspawn56 in forum Excel General
    Replies: 8
    Last Post: 12-25-2012, 12:01 PM
  4. [SOLVED] IF statement troubleshooting
    By MARKSTRO in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 12-14-2012, 08:30 PM
  5. Replies: 8
    Last Post: 11-22-2011, 07:45 PM
  6. SUMPRODUCT troubleshooting
    By CathB in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 05-10-2006, 10:10 AM
  7. [SOLVED] making drop downs "volatile"
    By Wazooli in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-09-2005, 09:06 PM

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