updating formulas that use user-defined functions

trf

Board Regular
Joined
Apr 17, 2002
Messages
62
I've defined a function as follows:

Function IsDataPoint(CellValue) As Boolean

If IsNumeric(CellValue) Then
IsDataPoint = True
ElseIf CellValue = "contact vendor" Then
IsDataPoint = False
ElseIf CellValue = "no quote, too thick" Then
IsDataPoint = False
Else
IsDataPoint = False
End If

End Function

I wrote the function in order to provide a flexible test for whether a certain value is a valid data point. At this time, we do not consider a value of "contact vendor" to be a valid data point, but at some time, we might. So I figured I would just use this function instead of the built-in isnumber function, and change the statements in the isdatapoint function according to whatever our latest definition of "data point" is.

But, Excel doesn't update the value returned by IsDataPoint when I change the code for the function -- unless I enter the formula window again and hit return. I've tried saving, closing and re-opening; there seems to be no easy automatic updating of the formula to reflect the new definition of the function.

Is there a workaround?

Thanks,
Rob
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
Hi Trf,

For a Function's result to be updated,the worksheet or workbook needs to Calculaute.
This can be achieved if a formula is calculated anywhere in the worksheet or by pressing F9.

In fact this applies to Excel Built-in Functions as well.

Hope this helps.
Jaafar.
 
Upvote 0
Try putting:

Application.Volatile True

as the first line in your function.

Normally a UDF is recalculated only when any of its arguments are modified. The above code causes the function to be recalculated whenever any cell is changed.

as an aside, to force a recalculation even if nothing has changed use Ctrl+Alt+F9.
 
Upvote 0
Thanks Andrew and Rafaaj! Both solutions work perfectly.

I thought I'd tried recalculating, but I guess not, because that worked.

Rob
 
Upvote 0

Forum statistics

Threads
1,214,653
Messages
6,120,750
Members
448,989
Latest member
mariah3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top