View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
joel joel is offline
external usenet poster
 
Posts: 9,101
Default Workaround for Excel 2002/2003 UDFs recalculating and changing cel

I would gete all the errors resolved and see how long it takes for the macro
to run before I make a decision to change the UDF functions.

The line below works in a new workbook in excel 2003

ActiveWorkbook.Names.Add Name:="This_Name", _
RefersToR1C1:="=Sheet1!R8C2"

I had to add a line continuation character to get the above line to run
without a compiler error.

It also runs multiples times without an error which indicates that It
Doesn't matter if the name already exists.

My suspect that you are having problems with which object is the active
object. For some reason the assumptions in excel 2000 and excel 2003 is
using as the default object has changed. Try run the macro with diffferent
worksheets as the activeworksheet and see if you can get the macro to run.
fix the problems one att a time until you get the entire macro to run.



"Ed Fulda" wrote:

Hello
I have been asked to look at moving a very large set of pricing sheets from
Excel 2000 to Excel 2003. In the progress of this I have found that the
functionality for a UDF in a cell to change/recalculate any other cells has
been removed in Excel XP, whereas it was available in Excel 2000. The amount
of work required to refactor the code is very large, and before starting on
it it would be good to find out if there is a workaround. The Sheet works in
the following way:
-User enters values, clicks a button to run a Macro,
-Macro calculates all the ranges required to return a price
-In many of the cells it is calculating are Functions which go and look at a
large number of cells to calculate the price, sometimes writing to other
Cells and sometimes having to recalculate other cells
-As it is such a large sheet we can't simply calculate all cells before we
tell it to price, as they are not all needed and so aren't calculated unless
needed for performance reasons.

It would be a lot of work to move the functionality from the Functions to
the initial macro call, though this would solve the problem. Is there any
other workaround?

Macro security is set to low.

The Errors I receive are the following:

The UDF will hit a line like Range("DataRange").Calculate and this will
raise a "Calculate method of Range class Failed" error.
If it hits a line like Range("DataRange").Value = 1 this will raise a
"Application-defined or object-defined error"
If it hits a line like ActiveWorkbook.Names.Add Name:="This_Name",
RefersToR1C1:="=Sheet1!R8C2" then it also raise a "Application-defined or
object-defined error".

Any of these run from a UDF in Excel 2000 works.

I have a sample workbook if this isn't clear