Home > Blockchain >  Excel Add in - Refresh only my custom functions in a specific sheet
Excel Add in - Refresh only my custom functions in a specific sheet

Time:06-10

I want to update custom formulas added my Excel add in. Using Application/worksheet.Caclulate() updates whole sheet, but I want to update only those cells which are using my formulas.

CodePudding user response:

The Application object provides a method to force an immediate recalculation. Application.calculate(calculationType) starts a manual recalculation based on the specified calculationType. The following values can be specified.

  • full: Recalculate all formulas in all open workbooks, regardless of whether they have changed since the last recalculation.
  • fullRebuild: Check dependent formulas, and then recalculate all formulas in all open workbooks, regardless of whether they have changed since the last recalculation.
  • recalculate: Recalculate formulas that have changed (or been programmatically marked for recalculation) since the last calculation, and formulas dependent on them, in all active workbooks.

So, you could play with an argument to get the required piece recalculated.

CodePudding user response:

I haven't tried this, but what if you used the technique described in Get formulas from a range of cells on the entire UsedRange of a worksheet. Then iterate through the returned array to find all the cells that have formulas matching one of yours. Then for each of those cells, call Calculate().

  • Related