+ Reply to Thread
Results 1 to 8 of 8

ListObject sort error 1004

  1. #1
    Registered User
    Join Date
    07-17-2017
    Location
    Boston, MA
    MS-Off Ver
    365
    Posts
    55

    ListObject sort error 1004

    I have 700 tables named RefTable1...RefTable700 that I'm trying to sort by the date column (column 3). This is the code I have, I am getting an error for the range not defined.
    (Feel free to suggest an entirely different way of doing this if it's better) Thanks!

    Please Login or Register  to view this content.
    Last edited by jeetkapadia; 08-23-2017 at 12:18 AM.

  2. #2
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: ListObject sort error 1004

    Your code works fine for me
    - VBA is not finding one of the tables
    - is there a table for every number?

    after this line
    Please Login or Register  to view this content.
    insert this line
    Please Login or Register  to view this content.
    and VBA sorts every table if finds
    Click *Add Reputation to thank those who helped you. Ask if anything is not clear

  3. #3
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,430

    Re: ListObject sort error 1004

    try

    Please Login or Register  to view this content.
    Cheers
    Andy
    www.andypope.info

  4. #4
    Registered User
    Join Date
    07-17-2017
    Location
    Boston, MA
    MS-Off Ver
    365
    Posts
    55

    Re: ListObject sort error 1004

    Hi kev_ and Andy,

    Thanks for the answer! On Error Resume Next works but I just printed out all the table names and they are all there, from 1 to 700. Any idea why this would happen?

  5. #5
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: ListObject sort error 1004

    No but you could start by finding out when it falls over. It may help.

    You need the Immediate Window Open in VBA
    either View\Immediate Window or shortcut {CTRL} g

    to allow it to fail again remove:
    Please Login or Register  to view this content.
    ... immediately below:
    Please Login or Register  to view this content.
    ...add this line:
    Please Login or Register  to view this content.
    DebugPrint will dump each value of "i" to the immediate window until the code fails.
    The last value is the one you want.

  6. #6
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,907

    Re: ListObject sort error 1004

    Have you tried
    Please Login or Register  to view this content.
    Avoid using Select, Selection and Activate in your code. Use With ... End With instead.
    You can show your appreciation for those that have helped you by clicking the * at the bottom left of any of their posts.

  7. #7
    Registered User
    Join Date
    07-17-2017
    Location
    Boston, MA
    MS-Off Ver
    365
    Posts
    55

    Re: ListObject sort error 1004

    Thanks kev! Got the problem. One of the tables was empty so it got stuck on the empty table.
    Bakerman, when header is yes, does range/databodyrange matter?

  8. #8
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: ListObject sort error 1004

    Thanks for the reps and for marking thread as SOLVED

+ 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. [SOLVED] Sort Macro Run-time error '1004': Application/Object-defined error.
    By sam1212 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-22-2014, 10:05 AM
  2. Sort 1004 error
    By GetSet in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-01-2010, 03:18 PM
  3. Sort: Run-time error '1004'
    By nbuk in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-16-2010, 12:20 PM
  4. VBA Sort 1004 Run-time error
    By Code Flunkie in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-15-2010, 03:13 PM
  5. Column Sort Macro 1004 error....
    By zapacoman in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-28-2008, 04:35 PM
  6. [SOLVED] Run-time error 1004 with sort
    By Linking to specific cells in pivot table in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-29-2005, 08:05 PM
  7. [SOLVED] RE: Run-time error 1004 with sort
    By Jim Thomlinson in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-29-2005, 05:05 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