ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Claiming Dependents (https://www.excelbanter.com/excel-programming/379921-re-claiming-dependents.html)

[email protected]

Claiming Dependents
 
Hi Gary,

I think the reason that its not working is that it will create a
circular refence (in effect) as your creating a dependant by using the
formula in the worksheet, I checked this by doing what you said but
instead of using your formula on a sheet go to the immediate window,
(you can do this by going into the vbe and pressing ctl + g) and
typing:
?Dep(Range("A1"))
This now shows the correct result.

The only way I could think for you to achieve this would be to put it
in a sub and run a loop for the cells you want to check, this obviously
wouldn't be dynamic though?!

James

Gary''s Student wrote:
In A1 I have 1
In B1 I have the formula =A1

When I run:

Sub dep2()
MsgBox (Range("A1").DirectDependents.Address)
End Sub

It correctly returns $B$1

The UDF, however

Function dep(r As Range) As String
dep = r.Dependents.Address
End Function

When used as
=dep(A1)
returns $A$1 Why?
--
Gary's Student




All times are GMT +1. The time now is 07:44 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com