LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #14   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default User Defined Function being called by changes to an independent workbook

On Jan 21, 4:57*pm, GS wrote:
armsiee explained :

I'm sorry if I haven't made myself clear but have kept trying to say
that I don't believe the UDF is the issue (which is why i did not post
it originally) it is a sympton of the problem. *It appears that the
"Test Sheet" recalculates itself whenever anything else happens within
that instance of Excel, eg, open another spreadhseet, type into a
blank spreadhseet and thus calls that UDF which produces errors (as it
is not specific with its Range declarations) sorry just missed the End
Function on the code snippet. *And yes the same behaviour occurs on a
colleagues workstation.


What I don't see in your UDF is how it knows NOT to run on any workbook
since there's no explicit ref to the workbook that uses it. You ref the
Range object in general and so Excel takes that to be a range on the
active sheet. IOW, your UDF (as written) should work with any open
workbook. I think <IMO you need to fully qualify the workbook that
it's to work with so Excel knows when/where it should be used. For
example, wrap your code in a With...End With construct something
like...

* Function MVA_Factor_Function(MVA_Expected_Return_Fac, _
* * * * * * * * * * * * * * * *MVA_Actual_Return_Fac, _
* * * * * * * * * * * * * * * *MVA_Minimum, MVA_Maximum, _
* * * * * * * * * * * * * * * *MVA_Max_Multiplier)

* * 'Set variables to be used in the calculation
* * Dim MVA_Ratio As Double

* * With ThisWorkbook.ActiveSheet
* * * 'Variables picked up from the input sheet
* * * MVA_Expected_Return_Fac = .Range("MVA_Expected_Return_Factor")
* * * MVA_Actual_Return = .Range("MVA_Actual_Return_Factor")
* * * MVA_Maximum = .Range("MVA_Max")
* * * MVA_Max_Multiplier = .Range("MVA_Max_Mult")
* * * MVA_Minimum = .Range("MVA_Min")
* * * '**Note the dot before Range.
* * End With

* * 'Calculate MVA as a ratio of the Actual return factor...
* * 'other code here...
* End Function

Also, if it happens whenever another workbook is activated then there
must be some code in an event that's causing it to execute, OR the test
workbook uses a similar named function also not restricted to that
workbook. Surely this would cause conflict that would cause unexpected
results.

--
Garry

Free usenet access athttp://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc


Yes thanks Garry, I have had similar thoughts, however this workbook
has been written like this and functioning for nearly 5 years with the
UDF code exactly the same (i've gone back and double checked through
the version history)

I have searched through the workbook to see if the UDF is called
anywhere else and the only place is the explicit reference within the
sheet, which leads me to believe that something else has happened to
the Workbook.

I can work around it, thanks for your efforts.
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
User Defined Function - Can we identify the cell it's called from Barb Reinhardt Excel Programming 5 March 21st 07 09:17 PM
Excel - User Defined Function Error: This function takes no argume BruceInCalgary Excel Programming 3 August 23rd 06 08:53 PM
Need to open the Function Arguments window from VBA for a user defined function. [email protected] Excel Programming 0 June 20th 06 03:53 PM
Using a user-defined function from the Personal workbook mworth01[_7_] Excel Programming 6 May 4th 06 02:12 PM
Using linked workbook as a parameter in a user defined function Michael[_20_] Excel Programming 1 November 28th 03 05:03 PM


All times are GMT +1. The time now is 01:42 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"