+ Reply to Thread
Results 1 to 15 of 15

How to automatically refresh formulas?

  1. #1
    Registered User
    Join Date
    12-13-2005
    Posts
    16

    How to automatically refresh formulas?

    I have Sheet1 with "formula"
    =MySheet!A1
    in e.g cell A1.
    Because MySheet does not exist in this workbook, I get #REF error.
    Later when I add MySheet, the #REF error is still there.
    But if I select A1 in Sheet1 and then click somwhere in the formula editor line and press ENTER, then A1 changes to 0 (or existing A1 value in MySheet)

    I wonder how to automatically refresh some/all formulas in Sheet1 that reference to MySheet, after MySheet is inserted.

    Please, see also attached file.
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    01-12-2007
    Location
    New Jersey
    Posts
    2,127
    This might help (I'm not sure). Pressing the F9 key on your keyboard recalculates the sheet for you. That should get rid of the error.

    Try it and report back.

  3. #3
    Registered User
    Join Date
    12-13-2005
    Posts
    16
    No, the only thing that works right now is to go to Formula bar and there press enter to confirm formula again. But do not want to do it manually for all cells.
    I tried to record a macro what it does is the following

    Range("A1").Select
    ActiveCell.FormulaR1C1 = "=MySheet!R[1]C"

    that is, it creates formula for that cell, not refresh it. Cause if I want to run this macro on another sheet, I will not get the real formula, but hte one hardcoded in macro
    Last edited by berti; 08-13-2007 at 10:23 AM.

  4. #4
    Forum Expert
    Join Date
    12-23-2006
    Location
    germany
    MS-Off Ver
    XL2003 / 2007 / 2010
    Posts
    6,326
    This way seems to work
    =INDIRECT("mysheet!"&"A1")

  5. #5
    Registered User
    Join Date
    12-13-2005
    Posts
    16
    Quote Originally Posted by arthurbr
    This way seems to work
    =INDIRECT("mysheet!"&"A1")
    It really does! Thank you!

  6. #6
    Forum Expert
    Join Date
    12-23-2006
    Location
    germany
    MS-Off Ver
    XL2003 / 2007 / 2010
    Posts
    6,326
    Glad to help and thx for the feedback

  7. #7
    Registered User
    Join Date
    07-13-2012
    Location
    sf usa
    MS-Off Ver
    Excel 2007
    Posts
    2

    Re: How to automatically refresh formulas?

    Here's a macro that bangs through all the formulae in all the sheets in the Active Workbook and forces an update. It's like so extremely cool I can't hardly even believe it.

    It resolves all the annoying #NAME? and #REF! errors before your very eyes, unless the formula is actually incorrect. It only touches cells with formulae.

    Please Login or Register  to view this content.
    I got bits and pieces of the code from hither and thither in the Great Encyclopedia of the Community of Coders. I don't wear a hat but if I did, it would be off to them.
    Last edited by arlu1201; 07-16-2012 at 02:19 PM. Reason: Use code tags

  8. #8
    Forum Contributor
    Join Date
    10-02-2012
    Location
    UK
    MS-Off Ver
    Office 365
    Posts
    293

    Re: How to automatically refresh formulas?

    Quote Originally Posted by sfsalvo View Post
    Here's a macro that bangs through all the formulae in all the sheets in the Active Workbook and forces an update. It's like so extremely cool I can't hardly even believe it.

    It resolves all the annoying #NAME? and #REF! errors before your very eyes, unless the formula is actually incorrect. It only touches cells with formulae.

    Please Login or Register  to view this content.
    I got bits and pieces of the code from hither and thither in the Great Encyclopedia of the Community of Coders. I don't wear a hat but if I did, it would be off to them.
    Works great if you don't have many formulas. When you have hundreds/thousands of cells that contain formulas, you might need to set a day aside while it works through.

  9. #9
    Registered User
    Join Date
    10-05-2012
    Location
    Kirkland, Washington
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: How to automatically refresh formulas?

    Below is updated to turn off screenupdating, which will significantly increase performance. Worked in about two minutes for >1500 linked cells using indirect function.
    Please Login or Register  to view this content.

  10. #10
    Registered User
    Join Date
    12-03-2012
    Location
    perth
    MS-Off Ver
    Excel 2003
    Posts
    1

    Re: How to automatically refresh formulas?

    Thanks for the code to refresh formulas, very useful!

  11. #11
    Registered User
    Join Date
    01-21-2013
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    1

    Re: How to automatically refresh formulas?

    Thank you very much for the code... its is really very useful...

  12. #12
    Registered User
    Join Date
    08-07-2013
    Location
    Richmond, Va
    MS-Off Ver
    Excel 2007
    Posts
    1

    Re: How to automatically refresh formulas?

    How would I rewrite the macro above if I just want to refresh the formulas on the active sheet. In other words, I want to put a button on the active sheet that when pressed, would refresh all formulas on that sheet only. Sorry, probably a simple answer but I am new to the VB language.

    Thanks.

  13. #13
    Registered User
    Join Date
    10-05-2012
    Location
    Kirkland, Washington
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: How to automatically refresh formulas?

    I believe you would get rid of the "
    Please Login or Register  to view this content.
    " portion, and
    Please Login or Register  to view this content.
    Basically that would eliminate the loop through every worksheet in the workbook and activesheet is a built in property.
    Please Login or Register  to view this content.

  14. #14
    Registered User
    Join Date
    01-28-2014
    Location
    work
    MS-Off Ver
    Excel 2010
    Posts
    1

    Re: How to automatically refresh formulas?

    Hi All,

    Sorry to resurrect this old thread.

    This is a really helpful bit of code, so thanks for posting it up!!

    I'd like to know if it is possible to set it to only update one cell in each worksheet, A1 for example?

    Basically I have a workbook with about 50 worksheets and I have a bit of code that pulls the colour as well as the text through to linked cells, but need to refresh one cell in each worksheet for it to update.

    The posted formula works perfectly as it is bt takes a couple of minutes to do it, if I could only update one cell per worksheet it would be much quicker.

    I know 90 seconds isn't a massive amount of time, but every little helps ay.

    Thanks very much for your help.

  15. #15
    Registered User
    Join Date
    10-05-2012
    Location
    Kirkland, Washington
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: How to automatically refresh formulas?

    You would need to change the rRange variable as follows:
    Please Login or Register  to view this content.
    At least that's what it would be for A1. You could also use the following:
    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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