Refresh Excel VBA Function Results

后端 未结 9 1003
悲&欢浪女
悲&欢浪女 2020-11-27 06:01

How can I get a user-defined function to re-evaluate itself based on changed data in the spreadsheet?

I tried F9 and Shift

9条回答
  •  时光取名叫无心
    2020-11-27 06:07

    This refreshes the calculation better than Range(A:B).Calculate:

    Public Sub UpdateMyFunctions()
        Dim myRange As Range
        Dim rng As Range
    
        ' Assume the functions are in this range A1:B10.
        Set myRange = ActiveSheet.Range("A1:B10")
    
        For Each rng In myRange
            rng.Formula = rng.Formula
        Next
    End Sub
    

提交回复
热议问题