Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to disable UDF while executing other sub

Status
Not open for further replies.

yakpol

Structural
Jun 1, 2001
450
I have a spreadsheet with a few user-defined function used in the worksheets. To speed up execution of other routins I need to temporarily disable UDF.

Thanks for your help!
 
Replies continue below

Recommended for you

Application.Calculation = xlCalculationManual


I haven't checked, but surely that switches off recalculation of all functions, including UDFs.

Doug Jenkins
Interactive Design Services
 
Doug,
I cannot turn off all calculations,I still rely on worksheet formulas to do most of the work.
 
OK, in that case how about having a worksheet cell named "RecalcFlag" then something like:

Function CalcIf(...)
If Range("RecalcFlag").Value = 1 Then

UDF code

Else
CalcIf = Application.Caller.Value
End If
End Function


Then you can set RecalcFlag to 0 whenever you don't want the UDF to recalc, but still show the original value. If you use that you will have to allow circular references (otherwise you get a warning message the first time any cell referenced by the function recalculates). I can't see a way to avoid that at the moment.

Doug Jenkins
Interactive Design Services
 
I seem to have the idea that a user function does not have to be defined with a global scope. If so, define it only in the sub where it is used.

What would you be doing, if you knew that you could not fail? Ans. Bonds and derivative brokering.
 
How adjusting security settings to disallow macros....does that disable udf's?

=====================================
(2B)+(2B)' ?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor