Article ID: 185387
Article Last Modified on 6/17/2005
=C2
-or-
=Sheet1!C2
='<hard drive>:documents:[WORKBOOK1]Sheet1'!$C$2
Option Explicit
Sub delete_external_names()
' Variable declarations.
Dim response As Integer
Dim msg As String
Dim flag As Boolean
Dim defined_name As Object
flag = True ' Check if external links were found.
' Loop through each defined name in workbook.
For Each defined_name In ActiveWorkbook.Names
' If a [ was found, then the name has a link.
If InStr(defined_name.RefersTo, "[") > 0 Then
flag = False ' set flag to False indicating a link was found
' Message displayed to ask if you want to delete name.
msg = "Do you want to delete the defined name " & "'" & _
defined_name.Name & "'" & Chr(13) & " that refers to '" & _
defined_name & "' ?"
' Delete the defined name.
If MsgBox(msg, 292) = vbYes Then defined_name.Delete
End If
Next defined_name ' Get the next defined name.
If flag = True Then ' If flag was not set, display message below.
MsgBox "No defined names with external were links found."
End If
End Sub
136314 Copying Sheets Between Workbooks Can Create Unexpected Links
Additional query words: XL98
Keywords: kbhowto kbmacro kbprogramming KB185387