View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.misc
Chip Pearson Chip Pearson is offline
external usenet poster
 
Posts: 7,247
Default VBA Created Worksheet Function Not Recalculating

Your function should get every value used in its calculation as an
input parameter to the function. E.g.,

Function GoodPlus(V1 As Double, V2 As Double) As Double
GoodPlus = V1+V2
End Function

If your function has cell references within it, Excel doesn't know
about them, so it will not calculate when one of those reference
values is changed. E.g.,

Function BadPlus(V1 As Double) As Double
BadPlus = V1 + Range("A1").Value
End Function

This function will not recalculate when A1 is changed, because Excel
has no knowledge that A1 is used by the function and doesn't see the
change in A1 to be a reason to recalculate the function.

Cordially,
Chip Pearson
Microsoft Most Valuable Professional,
Excel, 1998 - 2010
Pearson Software Consulting, LLC
www.cpearson.com



On Fri, 26 Feb 2010 07:37:01 -0800, Falcon Feet <Falcon
wrote:

I created my own Excel worksheet function in VBA. The function (formula)
works correctly when entered in a cell, but it does not recalculate when the
cell that the formula references changes. FYI, the workbook's "Calculation"
option IS set to Automatic.