+ Reply to Thread
Results 1 to 6 of 6

Macro with 4 sorting criteria

  1. #1
    Registered User
    Join Date
    04-30-2024
    Location
    Somers, NY
    MS-Off Ver
    Excel 2007
    Posts
    2

    Macro with 4 sorting criteria

    I have been using a macro with 3 sorting criteria since 1998. When I edit and put in a fourth criteria, I get an error (rum-time "1004". Application-defined or object-defined error). But it doesn't tell me what or where the error is to be fixed. I hope someone from this group can tell me how to fix. Here is my macro:

    ' Team Macro
    ' Macro recorded 3/22/98 by Meredith Powell
    '
    '
    Please Login or Register  to view this content.
    Any help would be greatly appreciated.
    Last edited by alansidman; 05-07-2024 at 11:43 AM.

  2. #2
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,650

    Re: Macro with 4 sorting criteria

    Range.Sort method has a limit of 3 criteria. And that's why Microsoft (AFAIK with Excel 2007) introduced Sort object.

    Your code rewritten with it would be:
    Please Login or Register  to view this content.
    Comment: You probably know whether your data has a header so it's better to use .Header = xlYes or xlNo
    Last edited by Kaper; 04-30-2024 at 11:36 AM.
    Best Regards,

    Kaper

  3. #3
    Registered User
    Join Date
    04-30-2024
    Location
    Somers, NY
    MS-Off Ver
    Excel 2007
    Posts
    2

    Re: Macro with 4 sorting criteria

    Hi Kaper,

    Thank you for trying to help me with my macro. Please note, I am not a programmer. I had someone else build this a long time ago for me. I tried copying your coding but still have errors. Here is what I did:

    Please Login or Register  to view this content.
    Can you write the exact code so I can just cut /copy/paste?
    Last edited by alansidman; 05-07-2024 at 11:43 AM.

  4. #4
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,650

    Re: Macro with 4 sorting criteria

    The code above was the full code, you used only part of it.

  5. #5
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2406 Win 11 Home 64 Bit
    Posts
    23,973

    Re: Macro with 4 sorting criteria

    @Mhattley
    Administrative Note:

    We would very much like to help you with your query, however your post does not comply with our guidelines

    Please take a moment to review how to add code tags. Posting code between [code]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/code] tags makes your code much easier to read and copy for testing, and it also maintains VBA formatting.

    Please see Forum Guideline #2 about code tags and adjust accordingly. Click on Edit to open your post, then highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here.

    I have added the code tags for you today. Please take a few minutes to re-read our guidelines and rules that you agreed to when you joined and comply in the future.
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  6. #6
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,336

    Re: Macro with 4 sorting criteria

    I suggest uploading a sample file depicting same setup as actual file and explain what 4 criteria you are wanting to sort...
    Good Luck
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the star to left of post [Add Reputation]
    Also....add a comment if you like!!!!
    And remember...Mark Thread as Solved.
    Excel Forum Rocks!!!

+ 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. Sorting list with Criteria
    By Nicolantonio in forum Excel General
    Replies: 0
    Last Post: 05-28-2021, 05:55 AM
  2. [SOLVED] Sorting Table By Two Criteria
    By Big.Moe in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 02-05-2020, 11:37 PM
  3. Sorting by date criteria
    By jbenkov in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-18-2014, 03:37 PM
  4. Please help to find a Macro to for filtering and sorting based on two criteria
    By 1Melina in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-21-2013, 12:54 PM
  5. Replies: 0
    Last Post: 05-15-2013, 09:18 AM
  6. Sorting and Delete rows meeting criteria based on sorting criteria
    By ron2k_1 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-10-2011, 02:40 PM
  7. Sorting rows in Macro with 4 criteria
    By minimacros in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-19-2010, 01:47 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