Results 1 to 4 of 4

Thread: How to handle: 'A query with this name already exists...'

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2002
    Posts
    382

    How to handle: 'A query with this name already exists...'

    I keep getting this message ("'A query with this name already exists on this sheet") even though I am deleting all visible queries within this workbook. How can I delete all external data queries so that this error does not occur? Thanks.

  2. #2

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2002
    Posts
    382

    Re: How to handle: 'A query with this name already exists...'

    I can't rerun the same data import query without either manually renaming the query within the properties window or deleting the worksheet. No matter what I try I cannot see the query anywhere, but its name contains the name of the text file I imported.
    Last edited by doasidont; Nov 11th, 2012 at 10:10 AM.

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2002
    Posts
    382

    Re: How to handle: 'A query with this name already exists...'

    More info. Seems like if you delete the external data query after you run it, you can run the same query to the same external file again. But if you save the workbook without deleting the query, that query stays forever and cannot be found and deleted unless you delete the entire sheet.

  4. #4
    Addicted Member
    Join Date
    Jul 2009
    Posts
    208

    Re: How to handle: 'A query with this name already exists...'

    Run this to delete all queries on the active sheet:
    Code:
        While ActiveSheet.QueryTables.Count
            ActiveSheet.QueryTables(1).Delete
        Wend

Posting Permissions

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



Click Here to Expand Forum to Full Width