I have written this simple UDF to make a computation in Excel spreadsheets. The code seems to work fine, but only once. However, if I change the values in the table (SharePriceGrowthTable), the results in the cells are not updated. Even when I hit F9 to re-calculate the sheet, the values in the cells where the function is used are not updated. I have verified that the Calculation option is set to Automatic.
Any ideas about what is going on or what I need to do different?
'Compute Stock Growth Score
Function StockGrowthScore(GrowthPercent As Double) As Double
Dim ScoreTable As Range
Set ScoreTable = Range("SharePriceGrowthTable")
If GrowthPercent >= 0 Then
StockGrowthScore = WorksheetFunction.VLookup(GrowthPercent, ScoreTable, 2)
Else
StockGrowthScore = -WorksheetFunction.VLookup(-GrowthPercent, ScoreTable, 2)
End If
StockGrowthScore = Application.Round(StockGrowthScore, 3)
End Function