+ Reply to Thread
Results 1 to 4 of 4

Runtime error 1004 when creating/formatting a table with VBA

  1. #1
    Registered User
    Join Date
    07-17-2013
    Location
    Stafford, TX
    MS-Off Ver
    Excel 2010
    Posts
    2

    Runtime error 1004 when creating/formatting a table with VBA

    Hi. I'm new to your forum; an amateur VBA programmer from the Houston area.

    I recorded this code in an attempt to create and format a table in Excel 2010.

    Please Login or Register  to view this content.
    When the ActiveSheet.ListObjects.Add(xlSrcRange, Selection, , xlYes).Name = "Master_List" statement executes, I get a runtime error 1004: "A table cannot overlap a range that contains a PivotTable report, query results, protected cells, or another table. "

    Earlier in the code I do import a .csv file to the range I'm trying to turn into a table. Looking in the name manager, it appears that every time the import runs, a new name gets created: inserts, inserts_1, inserts_2, etc. I think if I could delete these names (are they listobjects?) after the insert this problem might go away. In any case, I'd like to clean up after myself.

    Any suggestions?

    Thanks for any help.
    Last edited by BROnstott; 07-20-2013 at 06:33 PM.

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,202

    Re: Runtime error 1004 when creating/formatting a table with VBA

    If you are just trying to re-run the macro you recorded, it may be that the table already exists. Maybe you should try deleting it first.

    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Registered User
    Join Date
    07-17-2013
    Location
    Stafford, TX
    MS-Off Ver
    Excel 2010
    Posts
    2

    Re: Runtime error 1004 when creating/formatting a table with VBA

    Thanks, but it was the Query that was causing the problem. I solved the problem by deleting the query. I used this code:

    Please Login or Register  to view this content.
    Once I did that, all worked as expected. No error messages.

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,202

    Re: Runtime error 1004 when creating/formatting a table with VBA

    Ah, good to know you have a solution ... thank you for sharing it.


    If you are satisfied with the solution(s) provided, please mark your thread as Solved.


    New quick method:
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

    Or you can use this way:

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save


    You may also want to consider thanking those people who helped you by clicking on the little star at the bottom left of their reply to your question.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 0
    Last Post: 05-09-2012, 03:59 PM
  2. Excel 2007 pivot table/macro/Runtime error 1004
    By abalserv in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-01-2010, 06:36 AM
  3. Pivot Table runtime 1004 Error for certain users
    By jomili in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-13-2010, 05:11 PM
  4. Pivot table giving 'runtime error 1004'
    By wantucce in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-21-2007, 01:47 PM
  5. pivot table Commandtext causes runtime error 1004 in excel 2000
    By Therezee in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-11-2006, 11:45 PM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1