User Defined Function - actioned in unrelated WB

R

Richard

I have a user defined function contained within a Module Function
procedure in Workbook 1.

When I have a second workbook open, which has it's own macros and VBA
code - totally unrelated to Workbook 1, i.e. no links or similarly
named procedures, the second workbook seems to want to run through the
UDF contained in Wb 1.

In case it matters the same UDF is also held in my Personal.xls
workbook although it is the UDF in Wb1 that is being used.

How can I prevent the second workbook seeming to want to use the UDF in
the 1st Wb?

Usual TIA
 
N

NickHK

Richard,
Are you sure it not just a case of the UDF code being fired during the
normal course of the WS/WB re-calculation ?

NickHK
 
R

Richard Buttrey

Hi Nick,

Must admit I hadn't thought of that. I had naively assumed that if
values in a WS/WB were not changed, then the UDF would not
recalculate.

If this is indeed the case, is there any way of stopping the recalc in
a non active WB/WS?

Many thanks,




Richard,
Are you sure it not just a case of the UDF code being fired during the
normal course of the WS/WB re-calculation ?

NickHK

__
Richard Buttrey
Grappenhall, Cheshire, UK
__________________________
 
N

NickHK

Richard,
If this is a calculation issue, you can control when/how Excel calculates.

You can set Application.Calculation = xlCalculationManual (back to
xlCalculationAutomatic when ready).
Then you call .Calculate on the appropriate object ; Application, WorkSheet,
Range.

But why is a problem if the UDF is called anyway ?

NickHK
 
R

Richard Buttrey

Thanks Nick

When I noticed this I had the VBE open. This apparently slows UDF
calls down quite considerably. WIth the VBE closed it's much less of a
problem, but it still seemed to be taking about 20 seconds or so.

I suppose my question is really why does it have to call the UDF
anyway if the UDF is not related to the second WB?

I'll take up your suggestion of switching to xlCalculationManual and
experiment with calculating just the relevant range.

Kind regards,




Richard,
If this is a calculation issue, you can control when/how Excel calculates.

You can set Application.Calculation = xlCalculationManual (back to
xlCalculationAutomatic when ready).
Then you call .Calculate on the appropriate object ; Application, WorkSheet,
Range.

But why is a problem if the UDF is called anyway ?

NickHK

__
Richard Buttrey
Grappenhall, Cheshire, UK
__________________________
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top