View Single Post
  #10   Report Post  
Posted to microsoft.public.excel.programming
Peter T[_3_] Peter T[_3_] is offline
external usenet poster
 
Posts: 81
Default trouble returning a workbook level Name object

Brian,

This odd behavior becomes a real problem when trying
to do something like delete a book level name.


Do I take it you want to delete a book level name but keep
any/all sheet level names of the same name?

Trouble is Sheet names are both members both of the
worksheet.names collection and the workbook.names
collection. Maybe this might work:

Sub DelBookName()
Dim wk As Worksheet, nm As Name
Dim sName As String
sName = "somename"

For Each nm In ActiveWorkbook.Names

'if it's a sheet name should return "Sheetname!somename"
Debug.Print nm.Name

'does not include "Sheetname! so should be safe to delete
If nm.Name = sName Then nm.Delete
Next

End Sub

Regards,
Peter

<snip