Results 1 to 2 of 2
  1. #1
    Star Lounger
    Join Date
    Oct 2003
    Posts
    82
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hello I need a macro that will check a range of cells for dependents (Trace Dependent Function). Lets say I6:I942 and if it's NOT dependent to anything then highlight the entire cell in RED. Thank you.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    Try this:

    Code:
    Sub HighlightNoDependents()
      Dim rngSel As Range
      Dim oCell As Range
      Dim rngDep As Range
      Dim lngErr
      On Error GoTo ErrHandler
      Set rngSel = Selection ' or whatever you want
      rngSel.Interior.ColorIndex = xlColorIndexNone
      For Each oCell In rngSel.Cells
    	Set rngDep = oCell.Dependents
      Next oCell
      Exit Sub
    
    ErrHandler:
      oCell.Interior.ColorIndex = 3
      Resume Next
    End Sub
    This version acts on the current selection, but you can easily modify the line

    Set rngSel = Selection

    to suit your needs.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •