ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Finding when there are no directdependents (https://www.excelbanter.com/excel-programming/364751-finding-when-there-no-directdependents.html)

[email protected]

Finding when there are no directdependents
 
Hi all,

I have made a macro to perform an operation on all cells that
dependents of a specified cell. I want to exit the macro when the
specified cell has no dependents. Whatever I try causes an error.
Please could you give me some ideas how to achieve this effect? Here's
an example of what I tried:

If masterCell.DirectDependents.Count = 0 Then
Exit Sub
End If

but even the count property is invalid when the cell has no
directdependents.


Thanks, smu


Jim Thomlinson

Finding when there are no directdependents
 
Giive this a whirl...

Sub test()
Dim MasterCell As Range
Dim rng As Range

Set MasterCell = Range("A1")
On Error Resume Next
Set rng = MasterCell.DirectDependents
On Error GoTo 0
If rng Is Nothing Then
MsgBox "No Dependants"
Else
MsgBox rng.Address
End If

End Sub


--
HTH...

Jim Thomlinson


" wrote:

Hi all,

I have made a macro to perform an operation on all cells that
dependents of a specified cell. I want to exit the macro when the
specified cell has no dependents. Whatever I try causes an error.
Please could you give me some ideas how to achieve this effect? Here's
an example of what I tried:

If masterCell.DirectDependents.Count = 0 Then
Exit Sub
End If

but even the count property is invalid when the cell has no
directdependents.


Thanks, smu




All times are GMT +1. The time now is 01:52 AM.

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