+ Reply to Thread
Results 1 to 8 of 8

Thread: function (UDF) to execute "application.CalculateFullRebuild"

  1. #1
    Registered User
    Join Date
    01-09-2012
    Location
    MA
    MS-Off Ver
    Excel 2010
    Posts
    4

    function (UDF) to execute "application.CalculateFullRebuild"

    I am trying to use a UDF (loaded from an add-in) to force the active workbook to execute a application.CalculateFullRebuild. I am aware that the user can simply do a CTRL+ALT+SHIFT+F9. And I am also aware that I can run a sub with one line with
    line: application.CalculateFullRebuild

    or like so:

    Code:
    Sub calfullrebuild()
    
    Dim thisbook As Workbook
    Set thisbook = ThisWorkbook
    
    With thisbook
        .application.CalculateFullRebuild
    End With
    
    End Sub
    Again, the idea is to get this to work using a function (UDF) rather than via a sub.
    Or I would like the UDF to call this sub from an .xlam add-in that gets launched from XLStart.

    Anyone have any ideas for code that will solve this? Thanks for viewing

  2. #2
    Valued Forum Contributor p24leclerc's Avatar
    Join Date
    07-05-2010
    Location
    Québec
    MS-Off Ver
    Excel 2003-2010
    Posts
    377

    Re: function (UDF) to execute "application.CalculateFullRebuild"

    Why would you do this? If you have a cell with a formula calling your special function, I think it will recal itself endlessly.

  3. #3
    Registered User
    Join Date
    01-09-2012
    Location
    MA
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: function (UDF) to execute "application.CalculateFullRebuild"

    I am doing because the data that the UDF draws from (5 .dat files) is updated 1 x daily and is called via a dll. When the .dat files are changed and if Excel is already open and has instantiated the dll, I have difficulty getting excel to "bring in" the new data. I may not be explaining this exactly right but hopefully you get the point. So my question above is really just part of a much bigger issue I am trying to solve.

  4. #4
    Valued Forum Contributor OnErrorGoto0's Avatar
    Join Date
    12-30-2011
    Location
    I DO NOT POST HERE ANYMORE
    MS-Off Ver
    I DO NOT POST HERE ANYMORE
    Posts
    1,647

    Re: function (UDF) to execute "application.CalculateFullRebuild"

    You cannot, as far as I am aware, force calculation from a UDF since it would affect the Excel environment beyond returning a value and that is (generally) not permissible.
    Good luck.

  5. #5
    Registered User
    Join Date
    01-09-2012
    Location
    MA
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: function (UDF) to execute "application.CalculateFullRebuild"

    Bummer. Thanks for the input.

  6. #6
    Valued Forum Contributor OnErrorGoto0's Avatar
    Join Date
    12-30-2011
    Location
    I DO NOT POST HERE ANYMORE
    MS-Off Ver
    I DO NOT POST HERE ANYMORE
    Posts
    1,647

    Re: function (UDF) to execute "application.CalculateFullRebuild"

    I have just done some testing as this piqued my interest and it appears that:
    application.calculate is ignored
    Application.calculatefullrebuild does freeze excel
    Range.calculate causes the function to error and terminate.
    Good luck.

  7. #7
    Forum Guru snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,151

    Re: function (UDF) to execute "application.CalculateFullRebuild"

    Did you try refreshing the addin by VBA ?



  8. #8
    Registered User
    Join Date
    01-09-2012
    Location
    MA
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: function (UDF) to execute "application.CalculateFullRebuild"

    What does it mean to refresh the addin? Can you give an example? I did try to set the .cls file related to the dll to nothing, then unchecked the addin, then re-checked, then tried to instantiate the shelll.cls. But the existing functions on the open workbook did not update.

+ 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.2.0