Results 1 to 5 of 5

cleaning up obsolate names using For Each... In ... Next

Threaded View

  1. #1
    Registered User
    Join Date
    01-03-2012
    Location
    Poland
    MS-Off Ver
    Excel 2007
    Posts
    29

    cleaning up obsolate names using For Each... In ... Next

    I would greatly appreciate any help as I am totally stuck.

    When I delete a Range (i.e. column) with named cells the names are not deleted.
    I am trying to write a code to delete leftovers. So far I have:

    Sub CleanUp()
        For Each Name In ThisWorkbook.Names
            If Name = "*!REF!" Then
               'Name.Delete
               Debug.Print Name
            End If
        Next
    End Sub
    I use the Immediate window to check if I get any hits and "Names manager" to confirm that there should be.

    I have no idea what is wrong, as following works:
       For Each Name In ThisWorkbook.Names
                 Debug.Print Name
       Next
    as well as:
       For Each Name In ThisWorkbook.Names
            If Name = "=Sheet1!#REF!" Then
                   Name.Delete
            End If
       Next
    Last edited by Gzdnkh; 02-08-2012 at 09:02 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