Results 1 to 5 of 5

Log of External Links in the workbook

Threaded View

DUKE888 Log of External Links in the... 03-31-2011, 08:40 PM
broro183 Re: Log of External Links in... 03-31-2011, 08:47 PM
DUKE888 Re: Log of External Links in... 04-01-2011, 01:11 PM
snb Re: Log of External Links in... 04-01-2011, 01:35 PM
DUKE888 Re: Log of External Links in... 04-06-2011, 10:49 AM
  1. #1
    Registered User
    Join Date
    03-20-2009
    Location
    USA
    MS-Off Ver
    Excel 2003
    Posts
    14

    Log of External Links in the workbook

    Hi,

    Hope all is well. I have been trying to edit a macro to list out all the external links within the workbook in the tab name "ExternalLinks". The macro lists out Sheet Reference and the cell where the external link is located. But I'm keep on stumbling upon a Run-time error '1004': Application-defined or object-defined error on line If InStr(c.Formula, UserChoice) for the following code.

    The macro works if I change c.formula to c.value but that is not the result I'm looking for. Also, it will be an addition if the macro can list out the workbook & the tab named in external link in a separate columns.

    Below is the code:
    Sub FindExternalLinks()
        Dim X As Long, S As Worksheet, r As Range, A As Range, c As Range
        Dim External As Integer, UserChoice As String
        Dim nmName As Name, strRef As String
        
        Let X = 1
          
        On Error Resume Next
    
        Application.DisplayAlerts = False
        Worksheets("ExternalLinks").Delete
        Application.DisplayAlerts = True
        External = MsgBox(Prompt:="List external links only?", _
                                Title:="External or Ext & Internal", _
                                Buttons:=vbYesNoCancel)
    
        Select Case External
            Case vbCancel
                Exit Sub
            Case vbYes
    '           UserChoice = "\["
                UserChoice = ".xls"   ' Not all external links contain "\["
            Case Else
                UserChoice = "!"
        End Select
    
        On Error GoTo 0
    
        Worksheets.Add Before:=Sheets(1)
        ActiveSheet.Name = "ExternalLinks"
        Cells(1, 1).Formula = "Sheet Ref"
        Cells(1, 2).Formula = "Cell Ref"
        Cells(1, 3).Formula = "Formula"
        Cells(1, 5).Formula = "ExternalFileName"
        Cells(1, 6).Formula = "TabName"
    
        With Range("1:1")
            .Font.Bold = True
            .Font.ColorIndex = 5
            .Font.Size = 14
            .Font.Underline = True
        End With
    
        Range("A2").Select
        ActiveWindow.FreezePanes = True
        Application.ScreenUpdating = False
    
        For Each S In ActiveWorkbook.Worksheets
            Set r = Nothing
            On Error Resume Next
            Set r = S.UsedRange.SpecialCells(xlFormulas)
            On Error GoTo 0
            If Not r Is Nothing Then
            For Each A In r.Areas
    
                For Each c In A.Cells
                    If InStr(c.Formula, UserChoice) Then
                    X = X + 1
                    Worksheets("Formulas").Cells(X, 1) = S.Name
                    Worksheets("Formulas").Cells(X, 2) = c.Address(RowAbsolute:=False, ColumnAbsolute:=False)
                    Worksheets("Formulas").Cells(X, 3) = "'" & c.Formula
                    End If
                Next c
    
                
            Next A
            End If
        Next S
        Application.ScreenUpdating = True
        Application.DisplayAlerts = True
    
    End Sub
    Any help is much appreciated.
    Last edited by DUKE888; 04-06-2011 at 10:56 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1