LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default Identify each cell that has dependents

Below is a piece of code that I've been trying to modify. The code is
supposed to walk through the entire workbook and identify each cell
that has dependents. As I am working with a huge model, this would
take far too much time, and I would like to limit the macro to run
only a select few sheets. It would actually be even better if it only
ran on the active sheet, but I don't want to be picky. Any ideas?


=============================

Sub HighlightInputCells()

Dim wks As Worksheet
Dim rngFormulas As Range
Dim rngCell As Range
Dim vSheetLst As Variant

vSheetList = Array("Sheet2", "Sheet1")

Application.ScreenUpdating = False


For i = LBound(vSheetList) To UBound(vSheetList)
Worksheets(sheetlist(i)).Activate
On Error Resume Next
Set rngFormulas =
Union(wks.UsedRange.SpecialCells(xlCellTypeBlanks) ,
wks.UsedRange.SpecialCells(xlCellTypeConstants))
If Not rngFormulas Is Nothing Then
For Each rngCell In rngFormulas
If HasDependents(rngCell) Then rngCell.Interior.ColorIndex
= 3
Next rngCell
Set rngFormulas = Nothing
End If
Next wks
Application.ScreenUpdating = True

End Sub

Function HasDependents(rngCheck As Range) As Boolean
Dim lngSheetCounter As Long
Dim lngRefCounter As Long
Dim rngDep As Range

On Error Resume Next
With rngCheck
.ShowDependents False
Set rngDep = .NavigateArrow(False, 1, 1)
If rngDep.Address(external:=True) =
rngCheck.Address(external:=True) Then
HasDependents = False
Else
HasDependents = (Err.Number = 0)
End If
.ShowDependents True
End With
End Function
 
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 to traverse cell.Dependents joeu2004 Excel Programming 4 February 15th 08 12:10 PM
Checking cell for Dependents ExcelMonkey[_188_] Excel Programming 1 November 15th 04 01:11 PM
Checking cell for Dependents ExcelMonkey[_187_] Excel Programming 1 November 14th 04 11:33 AM
Checking cell for Dependents ExcelMonkey[_185_] Excel Programming 1 November 13th 04 09:20 PM
Checking cell for Dependents ExcelMonkey[_182_] Excel Programming 1 November 10th 04 01:02 AM


All times are GMT +1. The time now is 03:59 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"