#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default Referencing

I don't know what Isconnectiondead does, but maybe:

buf = Val(rng.Offset(0, 1).Text)
and
buf = val(rng.text)

(I didn't go through the error handler anyway.)

And I'm not sure what you're doing, but shouldn't this function be volatile?

Or pass it the address of the cell under it:
Public Function Rates(ByVal UseCache As Boolean, cellbelow as range) As Double

so in A1:
=rates(true,a2)



solex wrote:

Dave,

The "Text" property raises the same error. Per your suggestion below is the
relevant code.

Thanks,
Dan

Public Function Rates(ByVal UseCache As Boolean) As Double

Dim rng As Range
Dim buf As Double
Dim itersave As Boolean

On Error GoTo ErrorHandler

buf = 0#

itersave = Application.Iteration
Application.Iteration = True
' Here is the ticket per the documentation:
' If the callers is A custom function entered in a single cell then
' A Range object specifying that cell is returned
Set rng = Application.Caller

If IsConnectionDead Then
' Get the data from the cache
If UseCache Then
buf = rng.Offset(0, 1).Text ' <--- Generates the "circular
reference" error.
Else
' this will generate a circular reference error
' which can be turned of using the interations property
' in options/calculations and must be retained the next
' time the sheet is opened
buf = rng.Value
End If
Else
Call Randomize(0.03)
buf = Rnd
End If

ExitHandler:
Set rng = Nothing
Application.Iteration = itersave
Rates= buf
Exit Function

ErrorHandler:
'TODO Report Error?
Resume ExitHandler

End Function

"Dave Peterson" wrote in message
...
If you're referring to the .value property of the calling cell, try using

.text.

Or post the relevant portions of your function.

solex wrote:

Frank,

Thanks for the response, but I found the answer to my question,
Application.Caller does exactly what I would like, with the exception of
causing a Circular Reference error, which I cannot seem to turn off with
Application.Iterations=True.

This must be a bug since I should be able to bypass the Circular

reference
error with the Iterations property, have you seen anything with reagards

to
the Iterations property not working?

Thanks,
Dan

"Frank Kabel" wrote in message
...
Hi
not really sure what you're trying to do.<could you give an example?

--
Regards
Frank Kabel
Frankfurt, Germany


solex wrote:
Hello,
Is it possible to reference the current cells value that a
forumula/macro is working on?

I have a macro that retrieves values from a database, but if the
database is down I would like the macro to return the current value
of the cell is this possible?

Thanks,
Dan


--

Dave Peterson


--

Dave Peterson

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
Referencing Vanessa Simmonds Excel Discussion (Misc queries) 2 October 17th 08 11:49 AM
Referencing Help Teedie Excel Discussion (Misc queries) 3 July 3rd 08 08:41 AM
referencing a different tab by referencing a list in the current s Kevin Excel Worksheet Functions 3 July 6th 07 07:57 PM
referencing Richard[_2_] New Users to Excel 2 March 30th 07 01:50 AM
3-D referencing YBeaupre Excel Discussion (Misc queries) 0 September 4th 05 09:01 PM


All times are GMT +1. The time now is 09:25 AM.

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"