By using expertatexcel.com you agree to our cookie policy, We and our partners operate globally and use cookies, for multiple purposes

expertatexcel.com

 


DeleteExternalNames - deletes named ranges starting with External_ ' recorded

Sub DeleteExternalNames()

'this routine will delete the Named ranges that start with Eternal_

On Error Goto eh_deleteExternalNames

Dim i As Long
Dim r As Long
Dim sName as String

DeleteSheet "Work"

CreateSheet "Work"

If activesheet.name = "Work" then
   'ok
else
    Stop
End if

cells.Clear
Range("A1").ListNmaes

r = FindLastRow(1)

On Error Resume Next
For i = 1 to r
    If Mid(Cells(i, 1), 1, 13) = "ExternalData_" Then
        sName = Cells(i, 1)
        ActiveSheet.Names(sName).Delete
        If Err <> 0 then
            on Error Resume Next
        Else
            i = i
        End If
    End If
Next

DeleteSheet "Work"
Range("A1").Select
Exit Sub
eh_deleteExternalNames:
    Msgbox Err & " " & Error
    stop
    resume Next
    resume
End Sub

    


Next