+ Reply to Thread
Results 1 to 10 of 10

Refreshing results of custom formulas

  1. #1
    Forum Contributor
    Join Date
    03-11-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2016 (among others!)
    Posts
    331

    Refreshing results of custom formulas

    I've been playing around with grabbing information from web pages to help me out with somethign I am doing. Basically the workbook drags in a table from a webpage to give stats for each month over a number of years. I then have custom function that is a lookup. Given two variables provided by the user (or by the sheet itself) it grabs the relevant data. It works by cycling down the years till it finds the right one, then cycling the months and returning what is in the intersection. Works like a charm, except...

    If I refresh the external data the cell with the answer remains the same until I go into it to edit it then hit return. Refresh all doesn't work. Is there a way I can force the cell to recalculate? At the moment it is just one cell but once I get that working it is likely to be lots of cells (in no particular location).

  2. #2
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Refreshing results of custom formulas

    It would be helpful to see the code for your custom function, but most likely you can just add
    Please Login or Register  to view this content.
    to the start of it.
    Don
    Please remember to mark your thread 'Solved' when appropriate.

  3. #3
    Forum Contributor
    Join Date
    03-11-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2016 (among others!)
    Posts
    331

    Re: Refreshing results of custom formulas

    Found an answer that I'm managed to butcher. Ctrl+Alt+f9 seems to work for anyone landing here in future (including probably me!)

  4. #4
    Forum Contributor
    Join Date
    03-11-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2016 (among others!)
    Posts
    331

    Re: Refreshing results of custom formulas

    Thanks for that. I seem to recall there maybe being some issues with that bit of code. Or is that something blown out of all proportion?

  5. #5
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Refreshing results of custom formulas

    Could you be a little more specific? It makes your function volatile, which appears to be necessary. That in itself makes me think the function could be written better.

  6. #6
    Forum Contributor
    Join Date
    03-11-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2016 (among others!)
    Posts
    331

    Re: Refreshing results of custom formulas

    Nothing specific springs to mind, just remember seeing that bit of code before and the advice was not to use it. It works for what I need but I'd be interested to see if my code is any use or not. And in the interest of learning:

    Please Login or Register  to view this content.
    As background DC takes a variable (which in this situation would be the month - but ti has applications beyond that) and a year. The table is on sheet2 and is a simple case of years along the top months down the side. It was the simplest way I could think of doing it to be honest. I'm no coder, just someone who has dabbled with VBA / Excel for far too long!

  7. #7
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Refreshing results of custom formulas

    You aren't passing the lookup table to the range, so your function would have to be volatile. It looks to me as though a simple INDEX and MATCH formula would do what you need, and do it quicker.

  8. #8
    Forum Contributor
    Join Date
    03-11-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2016 (among others!)
    Posts
    331

    Re: Refreshing results of custom formulas

    I'll have to use application.worksheetfunction to get those to work, yes? I'd had issues with that before (Again a while back) but quite happy to give it a whirl instead (it was what I intended using until I remember previous problems).

    INcidentally when you say aren't passing the lookup table to the function.... do solve this do i name the table and then pass it as a third variable for instance? Then swap out any mention of the worksheet for the table?

  9. #9
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Refreshing results of custom formulas

    No, if you are using worksheet formulas, just use INDEX and MATCH; no need for Application.Worksheetfunction

    You don't have to name the table, you just need to pass it as a range to the function.

  10. #10
    Forum Contributor
    Join Date
    03-11-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2016 (among others!)
    Posts
    331

    Re: Refreshing results of custom formulas

    AH you meant use INDEX and MATCH on the sheet itself rather than in the formula. For the purposes of future development that won't work for me I don't think. But I think I can work with the passing the table as a solve to the problem. Well, if I can get it to work of course! Many thanks for your help. Much appreciated.

+ 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. [SOLVED] Strange Results with custom filter and arrays
    By colddeck84 in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 09-29-2017, 02:16 AM
  2. [SOLVED] Results from a custom function in Wb does not work when linked to another WB
    By kemit in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-11-2014, 08:54 AM
  3. Maintain Custom Sort when Refreshing Pivot Table Excel 2013
    By DavidMichaelangelo in forum Excel General
    Replies: 0
    Last Post: 05-28-2013, 10:41 AM
  4. Need help with having excel return custom algorithm results
    By jjjkkklll7777 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-27-2012, 08:10 PM
  5. DATEDIF and Custom format producing different results
    By Wirral Wizard in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 07-06-2010, 10:57 AM
  6. [SOLVED] Custom Autofilter yields no results
    By rjejyork in forum Excel General
    Replies: 4
    Last Post: 07-20-2006, 04:15 PM
  7. Refreshing formulas via VBA
    By longyp in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-01-2006, 08:17 AM

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