Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Listing External Worksheet references to your sheet

I am auditing workbooks with multiple references to external sheets
and wanted to create a list of the ranges which are being referenced,
without repeating the many duplicates which occur. The following
code, adapted from Bill Manville and Paul S from a thread dated Aug
14-5, 2001 creates a list of the unique external references.

Option Base 1
Public extPrec()
Sub runSheet()
Dim refColl As New Collection

For Each t In ActiveSheet.UsedRange
If InStr(t.Formula, "!") 0 Then
t.Activate
FindPrecedents
On Error Resume Next
Err.Number = 0
For Each r In extPrec
refColl.Add r, CStr(r)

Next
On Error GoTo 0

End If
Next

If refColl.Count 0 Then
nbrofRefs = refColl.Count

ReDim myReflist(nbrofRefs, 1)
For s = 1 To nbrofRefs
myReflist(s, 1) = refColl(s)
Next

refsheetname = ActiveSheet.Name & "refs"
Worksheets.Add befo=Sheets(1)
ActiveSheet.Name = refsheetname
Range("a1:a" & nbrofRefs) = myReflist
End If
End Sub


Sub FindPrecedents()
' this procedure finds the cells which are the direct precedents of
the
'active cell
Dim rLast As Range, iLinkNum As Integer, iArrowNum As Integer
Dim STMSG As String
Dim bNewArrow As Boolean
Application.ScreenUpdating = False
Erase extPrec

ActiveCell.ShowPrecedents
Set rLast = ActiveCell
iArrowNum = 1
iLinkNum = 1
bNewArrow = True
Do
Do
Application.Goto rLast
On Error Resume Next
ActiveCell.NavigateArrow TowardPrecedent:=True,
ArrowNumber:=iArrowNum, LinkNumber:=iLinkNum
If Err.Number 0 Then Exit Do
On Error GoTo 0
If rLast.Address(external:=True) =
ActiveCell.Address(external:=True) Then Exit Do
bNewArrow = False
If rLast.Worksheet.Parent.Name =
ActiveCell.Worksheet.Parent.Name Then
If rLast.Worksheet.Name = ActiveCell.Parent.Name Then
' local
' STMSG = STMSG & vbNewLine & Selection.Address
Else
' external
a = a + 1
ReDim Preserve extPrec(1, a)
If InStr(Selection.Parent.Name, " ") 0 Then
extShtName = "'" & Selection.Parent.Name & "'"
Else
extShtName = Selection.Parent.Name
End If
extPrec(1, a) = extShtName & "!" & Selection.Address
End If
Else
' external
a = a + 1
ReDim Preserve extPrec(1, a)
extPrec(1, a) = "'" & Selection.Address(external:=True)
End If
iLinkNum = iLinkNum + 1 ' try another link
Loop
If bNewArrow Then Exit Do
iLinkNum = 1
bNewArrow = True
iArrowNum = iArrowNum + 1 'try another arrow
Loop
rLast.Parent.ClearArrows
Application.Goto rLast
Exit Sub
End Sub
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
Automate External References Jeremy Excel Discussion (Misc queries) 0 November 6th 09 08:30 PM
Listing of cell references from a FIND All command. Joe Excel Discussion (Misc queries) 7 April 29th 07 11:44 AM
How to check if an excel sheet has external references. Daffo Excel Discussion (Misc queries) 3 August 16th 06 06:31 AM
External References Iain Excel Discussion (Misc queries) 1 February 3rd 05 09:45 AM
Listing all external links within a file Clayton McGuire Excel Programming 3 August 20th 03 10:04 AM


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