VBA- delete all defined names beginning "_service"

Thanks Thanks:  0
Likes Likes:  0
Results 1 to 4 of 4

Thread: VBA- delete all defined names beginning "_service"

  1. #1
    Board Regular
    Join Date
    Oct 2007
    Posts
    82
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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

User Tag List

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