Consulting

Results 1 to 3 of 3

Thread: Solved: Deleting name ranges (xl '97)

  1. #1
    VBAX Tutor phendrena's Avatar
    Joined
    Oct 2008
    Location
    Huddersfield, UK
    Posts
    285
    Location

    Solved: Deleting name ranges (xl '97)

    Greetings,

    I was wondering if there was a better way to delete named ranges using VBA. For example I have the following :-
    [VBA]ActiveWorkbook.Names("RangeName").Delete[/VBA]
    Now this fine for 1 or 2 named ranges, but what if you have a quite a few?
    Is it possible to delete a named range without actually naming the range or will i need to somehow get the names (and count them) and then loop through and delete them?

    Thanks,
    Somewhere in the dark and nasty regions where nobody goes, stands an ancient castle.
    Deep within this dank and uninviting place lives Berk, overworked servant of The Thing Upstairs.
    But thats nothing compared to the horrors that lurk beneath The Trap Door.

  2. #2
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    [VBA]
    Sub DelNames()
    Dim nm As Name
    For Each nm In ActiveWorkbook.Names
    nm.Delete
    Next
    End Sub

    [/VBA]
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  3. #3
    VBAX Tutor phendrena's Avatar
    Joined
    Oct 2008
    Location
    Huddersfield, UK
    Posts
    285
    Location
    Brilliant!
    Thank you so much!

    Somewhere in the dark and nasty regions where nobody goes, stands an ancient castle.
    Deep within this dank and uninviting place lives Berk, overworked servant of The Thing Upstairs.
    But thats nothing compared to the horrors that lurk beneath The Trap Door.

Posting Permissions

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