Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 683
Default Circular Reference Peculiarity

Hello,

I use circular references all the time without issues, however Im having
trouble when using user-defined functions in conjunction with circular
references.

Take the following simplified example:

Cell1: Revenue = 1000000 + Expenses * 3%

Cell2: Expenses = 700000 + Revenue * 2%

Where "Revenue" and "Expenses" are named ranges

The above formula works just fine assuming the calculation settings are
setup to allow circular references, but changing the formula to the following
creates problems:

Cell1: Revenue = RoundToNearest(1000000 + Expenses * 3%,5000)

Cell2: Expenses = 700000 + Revenue * 2%

Where RoundToNearest is a simple user-defined formula I created
to round numbers that's a bit more flexible than Excel's built-in Round
function (in the example above Revenue gets rounded to the
nearest $5,000). The error, however, occurs regardless of which
user-defined function I use.

When I open the worksheet containing the second example above, Cell1
(Revenue) and Cell2 (Expenses) contain #NAME? and #VALUE! respectively.
Oddly enough, if I delete Cell1 and press undo the error fixes itself.
However, I have to perform the delete and undo procedure every time I open
the file.

Does anyone have any thoughts on how to correct this problem? Thanks!



PS: The error occurs regardless of what user-defined function I use so I
don't think the error is specific to my RoundToNearest function.
Nevertheless, here's the function code:

Function RoundToNearest(x, Optional Threshold = 1) As Double

RoundToNearest = WorksheetFunction.Round(x / Threshold, 0) * Threshold

End Function
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,253
Default Circular Reference Peculiarity

Try:

Function RoundToNearest(x, Optional Threshold = 1) As Double
Dim dTmp As Double
If Not IsError(x) Then dTmp = x
RoundToNearest = Application.Round(dTmp / Threshold, 0) * Threshold
End Function



Note1:
escape from circulating errors

Note2:
iso worksheetfunction use application
(no intellisense, but different error handling
(see dick kusleika's blog)




--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


Brian wrote :

Hello,

I use circular references all the time without issues, however Im
having trouble when using user-defined functions in conjunction with
circular references.

Take the following simplified example:

Cell1: Revenue = 1000000 + Expenses * 3%

Cell2: Expenses = 700000 + Revenue * 2%

Where "Revenue" and "Expenses" are named ranges

The above formula works just fine assuming the calculation settings
are setup to allow circular references, but changing the formula to
the following creates problems:

Cell1: Revenue = RoundToNearest(1000000 + Expenses * 3%,5000)

Cell2: Expenses = 700000 + Revenue * 2%

Where RoundToNearest is a simple user-defined formula I created
to round numbers that's a bit more flexible than Excel's
built-in Round function (in the example above Revenue gets
rounded to the nearest $5,000). The error, however, occurs
regardless of which user-defined function I use.

When I open the worksheet containing the second example above, Cell1
(Revenue) and Cell2 (Expenses) contain #NAME? and #VALUE!
respectively. Oddly enough, if I delete Cell1 and press undo the
error fixes itself. However, I have to perform the delete and undo
procedure every time I open the file.

Does anyone have any thoughts on how to correct this problem? Thanks!



PS: The error occurs regardless of what user-defined function I use
so I don't think the error is specific to my RoundToNearest function.
Nevertheless, here's the function code:

Function RoundToNearest(x, Optional Threshold = 1) As Double

RoundToNearest = WorksheetFunction.Round(x / Threshold, 0) *
Threshold

End Function

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 683
Default Circular Reference Peculiarity

Thanks, KeepItCool. Unfortunately the error did not disappear. Any other
ideas?

"keepITcool" wrote:

Try:

Function RoundToNearest(x, Optional Threshold = 1) As Double
Dim dTmp As Double
If Not IsError(x) Then dTmp = x
RoundToNearest = Application.Round(dTmp / Threshold, 0) * Threshold
End Function



Note1:
escape from circulating errors

Note2:
iso worksheetfunction use application
(no intellisense, but different error handling
(see dick kusleika's blog)




--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


Brian wrote :

Hello,

I use circular references all the time without issues, however Im
having trouble when using user-defined functions in conjunction with
circular references.

Take the following simplified example:

Cell1: Revenue = 1000000 + Expenses * 3%

Cell2: Expenses = 700000 + Revenue * 2%

Where "Revenue" and "Expenses" are named ranges

The above formula works just fine assuming the calculation settings
are setup to allow circular references, but changing the formula to
the following creates problems:

Cell1: Revenue = RoundToNearest(1000000 + Expenses * 3%,5000)

Cell2: Expenses = 700000 + Revenue * 2%

Where RoundToNearest is a simple user-defined formula I created
to round numbers that's a bit more flexible than Excel's
built-in Round function (in the example above Revenue gets
rounded to the nearest $5,000). The error, however, occurs
regardless of which user-defined function I use.

When I open the worksheet containing the second example above, Cell1
(Revenue) and Cell2 (Expenses) contain #NAME? and #VALUE!
respectively. Oddly enough, if I delete Cell1 and press undo the
error fixes itself. However, I have to perform the delete and undo
procedure every time I open the file.

Does anyone have any thoughts on how to correct this problem? Thanks!



PS: The error occurs regardless of what user-defined function I use
so I don't think the error is specific to my RoundToNearest function.
Nevertheless, here's the function code:

Function RoundToNearest(x, Optional Threshold = 1) As Double

RoundToNearest = WorksheetFunction.Round(x / Threshold, 0) *
Threshold

End Function


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,253
Default Circular Reference Peculiarity


I DID test my code on your scenario.

With Iteration ON, MaxCount 100,MaxChange .001
This works for me in me in xl97,xlXP and xl2003.
Both while edited and saved/reopened.(code in same workbook)


--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


Brian wrote :

Thanks, KeepItCool. Unfortunately the error did not disappear. Any
other ideas?

"keepITcool" wrote:

Try:

Function RoundToNearest(x, Optional Threshold = 1) As Double
Dim dTmp As Double
If Not IsError(x) Then dTmp = x
RoundToNearest = Application.Round(dTmp / Threshold, 0) * Threshold
End Function



Note1:
escape from circulating errors

Note2:
iso worksheetfunction use application
(no intellisense, but different error handling
(see dick kusleika's blog)




--
keepITcool
www.XLsupport.com | keepITcool chello nl | amsterdam



Brian wrote :

Hello,

I use circular references all the time without issues, however
Im having trouble when using user-defined functions in
conjunction with circular references.

Take the following simplified example:

Cell1: Revenue = 1000000 + Expenses * 3%

Cell2: Expenses = 700000 + Revenue * 2%

Where "Revenue" and "Expenses" are named ranges

The above formula works just fine assuming the calculation
settings are setup to allow circular references, but changing the
formula to the following creates problems:

Cell1: Revenue = RoundToNearest(1000000 + Expenses *
3%,5000)
Cell2: Expenses = 700000 + Revenue * 2%

Where RoundToNearest is a simple user-defined formula I
created to round numbers that's a bit more flexible than
Excel's built-in Round function (in the example above
Revenue gets rounded to the nearest $5,000). The error,
however, occurs regardless of which user-defined function I
use.

When I open the worksheet containing the second example above,
Cell1 (Revenue) and Cell2 (Expenses) contain #NAME? and #VALUE!
respectively. Oddly enough, if I delete Cell1 and press undo the
error fixes itself. However, I have to perform the delete and
undo procedure every time I open the file.

Does anyone have any thoughts on how to correct this problem?
Thanks!



PS: The error occurs regardless of what user-defined function I
use so I don't think the error is specific to my RoundToNearest
function. Nevertheless, here's the function code:

Function RoundToNearest(x, Optional Threshold = 1) As Double

RoundToNearest = WorksheetFunction.Round(x / Threshold, 0) *
Threshold

End Function


Reply
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
Circular Reference [email protected] Excel Worksheet Functions 4 September 13th 09 04:59 PM
Circular reference help! nick Excel Discussion (Misc queries) 4 March 7th 06 08:07 PM
'circular reference' Rathika Excel Discussion (Misc queries) 2 January 26th 06 04:24 AM
Circular reference Pat Excel Discussion (Misc queries) 2 January 19th 05 05:52 AM
Circular Reference Tom Ogilvy Excel Programming 0 August 4th 04 06:50 PM


All times are GMT +1. The time now is 06:59 AM.

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

About Us

"It's about Microsoft Excel"