Getting Excel to refresh data on sheet from within VBA

前端 未结 6 1102
夕颜
夕颜 2020-11-27 06:14

How do you get spreadsheet data in Excel to recalculate itself from within VBA, without the kluge of just changing a cell value?

6条回答
  •  不知归路
    2020-11-27 06:46

    The following lines will do the trick:

    ActiveSheet.EnableCalculation = False  
    ActiveSheet.EnableCalculation = True  
    

    Edit: The .Calculate() method will not work for all functions. I tested it on a sheet with add-in array functions. The production sheet I'm using is complex enough that I don't want to test the .CalculateFull() method, but it may work.

提交回复
热议问题