updating formulas that use user-defined functions :: MrExcel Message Board



 FAQFAQ
   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   FavoritesFavorites   StatisticsStatistics 
 RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
Online StoreOnline Store

MrExcel Message Board Forum Index -> Excel Questions

updating formulas that use user-defined functions
Post new topic   Reply to topic
Last Thread | Next Thread  >   Printable version
  Author    Thread

trf
Board Regular


Joined: 18 Apr 2002
Posts: 47
Location: Denver, CO, USA

Status: Offline

 Reply with quote  

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

Post Mon Jan 27, 2003 6:09 pm 
 View user's profile Send private message

rafaaj2000
Board Master


Joined: 06 Dec 2002
Posts: 951
Location: Larache--Morocco
Flag: Morocco

Status: Offline

 Reply with quote  

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.

Post Mon Jan 27, 2003 6:25 pm 
 View user's profile Send private message Send e-mail

Andrew Poulsom
MrExcel MVP


Joined: 22 Jul 2002
Posts: 8203

Flag: Uk

Status: Offline

 Reply with quote  

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.

Post Mon Jan 27, 2003 6:26 pm 
 View user's profile Send private message

trf
Board Regular


Joined: 18 Apr 2002
Posts: 47
Location: Denver, CO, USA

Status: Offline

 Reply with quote  

Thanks Andrew and Rafaaj! Both solutions work perfectly.

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

Rob

Post Mon Jan 27, 2003 6:35 pm 
 View user's profile Send private message
  Display posts from previous:      

MrExcel Message Board Forum Index -> Excel Questions


Forum Jump:
Jump to:  

Post new topic   Reply to topic
Page 1 of 1



Add To Favorites

 


Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

Powered by phpBB: 2.0.4 © 2001 phpBB Group

Need help posting your first question? Read how to post

Need extra help ? Couldn't get the answer you needed ? Get a free quote from our Consulting Team

Download Colo's HTML Maker utility for displaying your Excel Worksheet on the board.

Download VB HTML Maker to post your code on the board


Check out our new index to 485 Excel Articles.


Return to MrExcel Consulting

All contents Copyright 1998-2004 by MrExcel.com
If you believe information posted here is from your copyrighted source, notify us per the Terms of Use
Excel is a registered trademark of the Microsoft Corporation.
MrExcel is a registered trademark of Tickling Keys, Inc.