Forum Discussion
Cell values not refreshing for custom function
- Mar 22, 2023
I want refresh calculation in this VBA code.
you can try adding the following line of code at the beginning of your function:
Application.Volatile
This will make sure that Excel recalculates the function every time there is a change in the worksheet. If this does not work, you can try adding a dummy argument to your function and changing its value every time you want to recalculate the function.
Here’s an example:
Application.Volatile Dim X As Double Dim Y As Long Y = CC.Interior.ColorIndex For Each I In RR If I.Interior.ColorIndex = Y Then X = X + I.Value End If Next I SumColoredCells = X End Function```
Hope I could help you with this information.
I know I don't know anything (Socrates)
I want refresh calculation in this VBA code.
you can try adding the following line of code at the beginning of your function:
Application.Volatile
This will make sure that Excel recalculates the function every time there is a change in the worksheet. If this does not work, you can try adding a dummy argument to your function and changing its value every time you want to recalculate the function.
Here’s an example:
Application.Volatile
Dim X As Double
Dim Y As Long
Y = CC.Interior.ColorIndex
For Each I In RR
If I.Interior.ColorIndex = Y Then
X = X + I.Value
End If
Next I
SumColoredCells = X
End Function```
Hope I could help you with this information.
I know I don't know anything (Socrates)