Sort by color using macro

jrisebo

Active Member
Joined
Mar 15, 2011
Messages
311
Office Version
  1. 365
Platform
  1. Windows
I have about 15 different groupings of data that are color coded (all in one column). So for "User1" button macro sorts by a color and puts it at the top. That still leaves 14 other colors, that I would like to be sorted, but it doesn't matter what color is next. Do I have to use brute force and have 15 different macros to get the color I want at the top, or is there a way to sort by color using buttons that will also sort all the other colors together, but no specific order.

For example, User1 would be green, User2 would be yellow, etc. User1 button brings green to the top, User2 button brings yellow to the top, etc.

Hope that makes sense.
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
I'm imagining a sort column (probably could be hidden or zero width). Code populates all rows of that column where interior (or is this a font colour?) is yellow (or green as the case may be) with the value of 1. It might be easier if you defined the order of the other colours though.
 
Upvote 0
I'm imagining a sort column (probably could be hidden or zero width). Code populates all rows of that column where interior (or is this a font colour?) is yellow (or green as the case may be) with the value of 1. It might be easier if you defined the order of the other colours though.

If i am following this, each color has a number. How would I then sort defining the color I want on top? For one instance it might be #3 i want on top, then #6, etc.
 
Upvote 0
You sort the 'sort' column (say that's column H) ascending? If you want yellow first, all H rows with yellow in a cell (no idea where that is) get a 1. After that, the rest are given values like 2 for red, 3 for blue, etc. When you sort H, 1's come first, 2's next and so on?
This is all just an idea on how you might accomplish this. I have never done it.
 
Upvote 0

Forum statistics

Threads
1,214,614
Messages
6,120,525
Members
448,969
Latest member
mirek8991

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top