+ Reply to Thread
Results 1 to 8 of 8

Sort range by alpha and then by font color with VBA

  1. #1
    Forum Contributor
    Join Date
    02-14-2014
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2013
    Posts
    328

    Sort range by alpha and then by font color with VBA

    I have a named range "Trade" (first column of range is A) which I would like to sort first by alpha and then by
    font color so that the black font items (ColorIndex = 1) will be on top and the pink font (ColorIndex = 7) items will be below.

    Can anyone help me with this?

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Sort range by alpha and then by font color with VBA

    Details are a bit vague, but try something like this...

    Please Login or Register  to view this content.
    Last edited by AlphaFrog; 03-30-2014 at 09:53 PM.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Forum Contributor
    Join Date
    02-14-2014
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2013
    Posts
    328

    Re: Sort range by alpha and then by font color with VBA

    Quote Originally Posted by AlphaFrog View Post
    Details are a bit vague, but try something like this...

    Thanks Alpha for helping out!

    Sorry that I wasn't clear enough.
    Right now your code is sorting, but only alpha, despite adding that column B and checking for the font values.

    I would like to sort by alpha AND by font colour.
    Is there a way to do it without creating that column B?
    I realize that it is deleted in the end.

    Thanks again!

  4. #4
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Sort range by alpha and then by font color with VBA

    Try this
    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    02-14-2014
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2013
    Posts
    328

    Re: Sort range by alpha and then by font color with VBA

    Quote Originally Posted by jindon View Post
    Try this
    Please Login or Register  to view this content.
    Thanks very much jindon for helping out!
    I really appreciate it.

    I ran the code in debug mode and it kept cycling in a loop at the point I have indicated above. The loop would not end.

  6. #6
    Forum Guru Izandol's Avatar
    Join Date
    03-29-2012
    Location
    *
    MS-Off Ver
    Excel 20(03|10|13)
    Posts
    2,581

    Re: Sort range by alpha and then by font color with VBA

    Do you still use Excel 2002 or later version? 2007 or later version may sort by colour.
    • Please remember to mark threads Solved with Thread Tools link at top of page.
    • Please use code tags when posting code: [code]Place your code here[/code]
    • Please read Forum Rules

  7. #7
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Sort range by alpha and then by font color with VBA

    Can you upload a small sample workbook with before/after format?

  8. #8
    Forum Contributor
    Join Date
    02-14-2014
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2013
    Posts
    328

    Re: Sort range by alpha and then by font color with VBA

    Thanks for helping out Izandol and Jindon.
    I am still using 2002.

    Today I will consider making a big change in my workbook!
    I think I will use two sheets instead of one for my calculations.

    That way I can put my 'active trades' (black) on one page and my 'scenario trades' on a second page (pink).

    By doing this, I wouldn't need to have two criteria for the sorts (alpha + color).
    For now I will mark the thread 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. Sort by font Color
    By Laslo1 in forum Excel General
    Replies: 9
    Last Post: 03-08-2012, 07:37 PM
  2. Sort by font color after sorting by separate variable
    By RedWing in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-10-2011, 09:10 AM
  3. Sort a column based on Font Color
    By tdyl1969 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-16-2010, 11:30 AM
  4. sort cells by font color
    By baz0912 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-25-2008, 02:09 PM
  5. Sort or sub-total by Fill color or font color
    By Excel_seek_help in forum Excel General
    Replies: 1
    Last Post: 04-27-2006, 04:10 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