Results 1 to 4 of 4

Runtime error 1004 when creating/formatting a table with VBA

Threaded View

  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.

    '
        NumRows = Application.WorksheetFunction.CountA(Worksheets("Master List").Range("D:D"))
    '
    ' Format table
    '
        Worksheets("Master List").Range("A1:H" & NumRows).Select
        Selection.Style = "Normal"
        ActiveSheet.ListObjects.Add(xlSrcRange, Selection, , xlYes).Name = "Master_List"
        ActiveCell.Range("Master_List[#All]").Select
        ActiveSheet.ListObjects("Master_List").TableStyle = "TableStyleMedium9"
    '
    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.

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