View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Phillip[_5_] Phillip[_5_] is offline
external usenet poster
 
Posts: 33
Default Delete named ranges in VBA - by scope?

On Jul 22, 8:53*pm, Revolvr wrote:
Is there a way to delete all occurrences of a named range that is
scoped to a worksheet level only?

I have a workbook with workbook level named ranges. People sometimes
copy a sheet resulting in another occurrence of the same named range,
but scoped to the worksheet level. This screws up a bunch of charts. I
need a way to delete these if it happens.

Thanks!


Phillip London UK


Try this

Sub RemoveSheetLevelNames()

For r = 1 To Names.Count
If InStr(1, Names(r).Name, "!") Then
MsgBox Names(r).Name & " is a sheet level name"
Names(r).Delete
End If
Next
End Sub