View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
JNW JNW is offline
external usenet poster
 
Posts: 480
Default Loop through cells to find dependents

I having brain issues...

I've completely forgotten how to trap an error in a loop

Here is what I have (watch out for lines wrapping):
Sub MapDependencies()
Dim cell As Range
For Each cell In ThisWorkbook.Sheets("Summary").Range("A1:L64")

ThisWorkbook.Sheets("Dependencies").Range("b65000" ).End(xlUp).Offset(1,
0).Value = cell.DirectDependents.Address

ThisWorkbook.Sheets("Dependencies").Range("b65000" ).End(xlUp).Offset(0,
-1).Value = cell.Address
Next cell
End Sub

Cell A1 has no dependencies, so error 1004 'No cells were found' pops up. I
can trap the first error in the loop, but if any other subsequent cell errs
then it is no longer trapped.

Any ideas?