Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 427
Default Does a HasDependents = True property exist?

Does VBA code exist that returns a True when a cell has one or more
dependents?

Thanks
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,549
Default Does a HasDependents = True property exist?

You have to roll your own.
There is a HasFormula property for a cell.
There is also a Precedents and a Dependents property that returns a Range object.
So...

Function AreThereKids(ByRef CellPassedIn As Range) As Boolean
Dim objRng As Range
On Error Resume Next
Set objRng = CellPassedIn.Dependents
On Error GoTo 0
AreThereKids = Not objRng Is Nothing
End Function
--
Jim Cone
Portland, Oregon USA
(xl2003 color sorting... http://www.contextures.com/excel-sort-addin.html)



"Dave O"
wrote in message ...
Does VBA code exist that returns a True when a cell has one or more
dependents?

Thanks
  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 427
Default Does a HasDependents = True property exist?

Jim-
Thanks for your note. Not to be picky: is there a way to write that
same code as a routine, rather than a function? Here's my deal: I've
written code (below) to check if a range contains any values (so I can
know whether it is safe to delete). I'd like to incorporate code that
checks each cell to see if that cell has dependents, so I know not to
delete the cell even if it is empty (since deleting the cell causes a
#REF! error in dependent cells).

Your suggestion is excellent- however if I use the function in a
spreadsheet cell, the function itself becomes a dependent of the cell,
and returns a false positive.

Any ideas?

code follows:
Sub WhatsInRange()
Dim rCell As Range
For Each rCell In Selection
If rCell.Value < "" Then
Range(rCell.Address).Select
End
End If
Next rCell
MsgBox "Nothing found."
End Sub

Thanks again,
Dave O
  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,549
Default Does a HasDependents = True property exist?

You can call functions/subs from functions or subs.
'--
Sub WhatsInRange_R1()
Dim rCell As Range
For Each rCell In Selection.Cells
If IsEmpty(rCell) Then
If AreThereKids(rCell) = False Then
Range(rCell.Address).Select
Exit Sub
End If
End If
Next 'rCell
MsgBox "Nothing found."
End Sub

Function AreThereKids(ByRef CellPassedIn As Range) As Boolean
Dim objRng As Range
On Error Resume Next
Set objRng = CellPassedIn.Dependents
On Error GoTo 0
AreThereKids = Not objRng Is Nothing
End Function
--
Jim Cone
Portland, Oregon USA
(free excel add-in to remove excess Styles or Cond. Formats... http://excelusergroup.org/media/p/4861.aspx )





"Dave O"
wrote in message ...
Jim-
Thanks for your note. Not to be picky: is there a way to write that
same code as a routine, rather than a function? Here's my deal: I've
written code (below) to check if a range contains any values (so I can
know whether it is safe to delete). I'd like to incorporate code that
checks each cell to see if that cell has dependents, so I know not to
delete the cell even if it is empty (since deleting the cell causes a
#REF! error in dependent cells).

Your suggestion is excellent- however if I use the function in a
spreadsheet cell, the function itself becomes a dependent of the cell,
and returns a false positive.

Any ideas?

code follows:
Sub WhatsInRange()
Dim rCell As Range
For Each rCell In Selection
If rCell.Value < "" Then
Range(rCell.Address).Select
End
End If
Next rCell
MsgBox "Nothing found."
End Sub

Thanks again,
Dave O
  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 427
Default Does a HasDependents = True property exist?

Your kung fu is vastly superior!

Thanks for your help~

Dave O
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
how excel calculates the major units on an axis when MajorUnitIsAuto property set to true [email protected] Charts and Charting in Excel 1 May 15th 07 04:06 PM
how excel calculates the major units on an axis when MajorUnitIsAuto property set to true [email protected] Charts and Charting in Excel 0 May 15th 07 08:39 AM
how excel calculates the major units on an axis when MajorUnitIsAuto property set to true [email protected] Excel Discussion (Misc queries) 0 May 15th 07 07:35 AM
Function to return True/False if all are validated as True by ISNU Tetsuya Oguma Excel Worksheet Functions 2 March 15th 06 10:28 AM
If "text" exist within "cell" then TRUE JemyM New Users to Excel 7 September 17th 05 12:41 AM


All times are GMT +1. The time now is 05:53 PM.

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"