+ Reply to Thread
Results 1 to 2 of 2

How to sort by cell value and then by color

  1. #1
    Registered User
    Join Date
    07-28-2021
    Location
    Illinois
    MS-Off Ver
    365
    Posts
    2

    How to sort by cell value and then by color

    Hello, I created a macro and I am having some trouble with a portion of it. During one part, it looks at a column of numbers and adds a fill color to the cell based on the value. It'll be red if it's 0 or #N/A, orange if it's greater than 0 but less than or equal to 7, yellow if it's greater than 7 but less than or equal to 14, and then left white if it's greater than 14. I then want to sort this data. I recorded a macro to sort it by color in ascending order going red, orange, yellow, and then white (see code below). Normally, I would just sort by low to high value but I need the #N/A to be at the top with the 0's so that's why I decided to sort by color instead. But the problem is that the sorting within the color categories is not numerical. I can manually go in and sort by the value from low to high and then by color, but I want the macro to do it and I can't seem to get the code to work to do that. Would anyone be able to modify the code below so it sorts by the value and then sorts by the color? Thank you! Since this is recorded code it is messy, so also feel free to tell me what I could do to simplify it, as well.
    Please Login or Register  to view this content.
    Moderator's note: Please take the time to review our rules. There aren't many, and they are all important. Rule #2 requires code tags. I have added them for you this time because you are a new member. --6StringJazzer
    Last edited by 6StringJazzer; 08-26-2021 at 04:04 PM.

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: How to sort by cell value and then by color

    Can you provide your sample data file so we have something to run your code on?
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

+ 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. Sort rows by cell color
    By Sgligori in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 06-12-2016, 09:24 PM
  2. [SOLVED] How can I sort a range by cell color
    By Gunner222 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 04-25-2014, 08:12 PM
  3. [SOLVED] sort by cell fill color
    By trisoldee in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-05-2013, 10:43 AM
  4. Want to sort by rows - Cell color
    By SVTF in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 04-10-2011, 11:43 PM
  5. Is there a way to sort By highlighted cell color?
    By tvance929 in forum Excel General
    Replies: 4
    Last Post: 11-20-2007, 03:46 PM
  6. Sort by Cell Color
    By sjs in forum Excel General
    Replies: 2
    Last Post: 05-08-2006, 11:45 AM
  7. [SOLVED] how to sort according to the cell color?
    By sam in forum Excel General
    Replies: 1
    Last Post: 11-18-2005, 01:10 AM

Tags for this Thread

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