Results 1 to 4 of 4

VBA- delete all defined names beginning "_service"

This is a discussion on VBA- delete all defined names beginning "_service" within the Excel Questions forums, part of the Question Forums category; how can i delete about 1000 of a total of 8000 defined names? the ones i want to delete begin ...

  1. #1
    Board Regular
    Join Date
    Oct 2007
    Posts
    82

    Default VBA- delete all defined names beginning "_service"

    how can i delete about 1000 of a total of 8000 defined names? the ones i want to delete begin "_service"

    thanks

  2. #2

    Join Date
    Feb 2003
    Location
    Gurgaon/Thrissur
    Posts
    2,615

    Default Re: VBA- delete all defined names beginning "_service"

    Hi,

    Code:
    Sub DeleteNames()
    Dim Ns    As Name
    Const NameStr   As String = "_service"
    For Each Ns In ThisWorkbook.Names
        If LCase(Left$(Ns.Name, 8)) = NameStr Then
            Ns.Delete
        End If
    Next
    End Sub
    HTH

  3. #3
    Board Regular
    Join Date
    Oct 2007
    Posts
    82

    Red face Re: VBA- delete all defined names beginning "_service"

    Hi thanks

    i need to actually delete all names beginning with "_Service"

    I tried changing code to

    Const NameStr As String = "_service"

    but i think the LCase function is effecting it?? is it ignoring my uppercase letter?

    please help

  4. #4
    Board Regular
    Join Date
    Oct 2007
    Posts
    82

    Default Re: VBA- delete all defined names beginning "_service"

    dont worry, did it

    replace
    Code:
    If LCase(Left$(Ns.Name, 8)) = NameStr Then
    with
    Code:
    If Left$(Ns.Name, 8) = NameStr Then

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


DMCA.com