View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Zoo Zoo is offline
external usenet poster
 
Posts: 40
Default How do I turn around 'Circulation Reference' msgbox?

Thank you for your reply , NichHK.

Application.Caller Is set to Sheet1.Range("A1") in this case.
When I type the formula '=TEST()' , Application.Caller.Parent is Sheet1.
Since Sheet1 is activated by me to enter the formula,
Application.Caller.Parent(Sheet1) is ActiveSheet, and TEST returns
Format(Now, "HH:MM:SS").

When I activate Sheet2, TEST returns the already calculated value (A1's
value itself).

The purpose of this macro is to try to make UDF being recalculated only when
the sheet is activated.

"NickHK" wrote in message
...
Zoo,
Apart from the fact that your function no return value (As String), check
the value in the Immediate window:

?typename(Application.Caller), Application.Caller
Double 468385800

The Help does not mention a return value of Double, so I would assume it
some error code
I guess your were expecting it to evaluate to the range "A1".

I do not use these properties so I can't advise you other than the above.

NickHK


"Zoo" wrote in message
...
I have a UDF named Test() written below.
And I put it into Sheet1.A1 : = Test()
And I activate Sheet2 and press Ctrl + Alt + F9 (CalculateFull).
Then a msgbox is shown : 'There is a circulation reference....'
I want to turn around the msgbox.
(I tried setting Apllication.DisplayAlerts property to false in vain.)

'---------UDF -------------------------------
Function TEST()
If Not Application.Caller.Parent Is ActiveSheet Then
TEST = Application.Caller.Value
Exit Function
End If
TEST = Format(Now, "HH:MM:SS")
End Function