Posted 24 October 2024, 2:23 am EST
Hi,
You are right that when the workbook’s Dirty method is called, all the formulas present in the workbook are recalculated and may impact performance. To tackle this scenario, you can use IWorksheet’s Dirty method (updates state of all the formulas present in the worksheet) or IRange’s Dirty method (updates state of all the formulas present in the specified range) instead of Workbook’s Dirty method.
When DeferUpdateDirtyState is true, other formulas of the worksheet work perfectly without calling the Dirty method because when a range containing the formula is accessed, the value of the cells containing the formula are recalculated and updated values are returned.
Due to the same reason as above, when you access cell B3 without calling the Dirty method, the value is 0 and when you access the cell B2 containing the formula, the values are recalculated and cell B3 returns value 600.
Please refer to the attached sample that updates the value of cell B3 before cell B2 is invoked by just setting the state of cell B2 to dirty. Please feel free to reach out if you have any further issues or if any further guidance is required.
Attachment: DynamicArrayNotCalculated_updated3.zip
Best Regards,
Kartik