Consulting

Results 1 to 3 of 3

Thread: Solved: How can I delete all Queries in workbook?

  1. #1
    VBAX Regular
    Joined
    Jun 2008
    Posts
    6
    Location

    Solved: How can I delete all Queries in workbook?

    I have an 8 sheet workbook that has had queries added over a period of time. I wish to delete them all. I have deleted the ranges where the queries have been previously used but if I attempt to create a new query using a name that has already been used, Excel won't allow it.

    So these old queries are stored somewhere??? Can't find them however.

    Another indication I get that they are still floating in the workbook somewhere, is that the Range name box in the toolbar lists all the queries ever created.

    How do I do this?

  2. #2
    1. Download my Name Manager from
    www.jkp-ads.com/officemarketplacenm-en.asp
    Use it to get rid of the query range names
    2. Run this code:
    Sub RemoveQT()
        Dim oQT As QueryTable
        Dim oSh As Worksheet
        For Each oSh In Worksheets
            For Each oQT In oSh.QueryTables
                oQT.Delete
            Next
        Next
    End Sub
    Regards,

    Jan Karel Pieterse
    Excel MVP jkp-ads.com

  3. #3
    VBAX Regular
    Joined
    Jun 2008
    Posts
    6
    Location
    Thankyou for that great tool! I tried the code but that didn't do anything. However, after reading the instructions with your Name Manager tool, I found all the named queries and was able to quickly delete them.

    Kudos to JKP!

Posting Permissions

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