Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 01-31-2014, 10:36 AM
Kreol2013 Kreol2013 is offline Is it possible to sort cells in shades of colors? Windows 7 32bit Is it possible to sort cells in shades of colors? Office 2013
Novice
Is it possible to sort cells in shades of colors?
 
Join Date: Apr 2013
Posts: 8
Kreol2013 is on a distinguished road
Question Is it possible to sort cells in shades of colors?

Welcome!
Is it possible to sort cells in shades of colors?


thanks in advance.
Attached Files
File Type: xlsx Color.xlsx (93.3 KB, 22 views)
Reply With Quote
  #2  
Old 01-31-2014, 06:40 PM
excelledsoftware excelledsoftware is offline Is it possible to sort cells in shades of colors? Windows 7 64bit Is it possible to sort cells in shades of colors? Office 2003
IT Specialist
 
Join Date: Jan 2012
Location: Utah
Posts: 455
excelledsoftware will become famous soon enough
Default

Yes but you need to do it with VBA. Basically each of those colors has a color index # that you can sort by. You could use this code.
Code:
Sub FillColorIndex()
    'Takes the index of a color and places it in the cell next to the data
        Dim ColorRow As Integer, TotalRows As Integer
        
            TotalRows = WorksheetFunction.CountA(Range("b:b").Rows)
            
            For ColorRow = 2 To TotalRows
                Range("d" & ColorRow).Value = Range("b" & ColorRow).Interior.ColorIndex
            Next ColorRow
            
            MsgBox "All Rows Complete"

End Sub
That will give you a number for each of the colors. Now I am guessing that you want each of those colors to grouped ie. Reds with reds, blues with blues etc. The colorindex will not quite do that but you can sort the numbers and change them as you wish to sort them after.
Reply With Quote
  #3  
Old 02-01-2014, 01:04 AM
jolivanes jolivanes is offline Is it possible to sort cells in shades of colors? Windows XP Is it possible to sort cells in shades of colors? Office 2007
Advanced Beginner
 
Join Date: Sep 2011
Posts: 93
jolivanes will become famous soon enough
Default

If you're happy with RGB sorting?
See attached
Attached Files
File Type: xlsm Color_Sort.xlsm (112.5 KB, 41 views)
Reply With Quote
  #4  
Old 02-01-2014, 02:11 AM
gasyoun gasyoun is offline Is it possible to sort cells in shades of colors? Windows 7 32bit Is it possible to sort cells in shades of colors? Office 2007
Novice
 
Join Date: Apr 2013
Posts: 5
gasyoun is on a distinguished road
Default

Quote:
Originally Posted by excelledsoftware View Post
That will give you a number for each of the colors. Now I am guessing that you want each of those colors to grouped ie. Reds with reds, blues with blues etc. The colorindex will not quite do that but you can sort the numbers and change them as you wish to sort them after.
There are 24k colors. Do I understand you right, that you propose to sort them manually? Even RGB gives you blue that can look like grey, because of the intensity. Can color and color intensity be taken into account? I'm a big fan of manual labor in Excel. But 24 000 rows is too many even for me.

http://labs.tineye.com/color/001c85d...True&height=32 does an interesting job, but still no enough.
Reply With Quote
  #5  
Old 02-02-2014, 11:24 AM
excelledsoftware excelledsoftware is offline Is it possible to sort cells in shades of colors? Windows 7 64bit Is it possible to sort cells in shades of colors? Office 2003
IT Specialist
 
Join Date: Jan 2012
Location: Utah
Posts: 455
excelledsoftware will become famous soon enough
Default

Upon further searching it appears that there may actually be a custom sorting option in your version of Excel.
http://spreadsheets.about.com/od/dat...olor-excel.htm

I was not aware of this but looks like you can accomplish what you need quite easily afterall.
Reply With Quote
  #6  
Old 02-02-2014, 01:52 PM
Kreol2013 Kreol2013 is offline Is it possible to sort cells in shades of colors? Windows 7 32bit Is it possible to sort cells in shades of colors? Office 2013
Novice
Is it possible to sort cells in shades of colors?
 
Join Date: Apr 2013
Posts: 8
Kreol2013 is on a distinguished road
Thumbs up

As I had not thought of repeatedly apply sorting for each color. Thank you for the correct path.
Reply With Quote
  #7  
Old 02-03-2014, 02:32 AM
Kreol2013 Kreol2013 is offline Is it possible to sort cells in shades of colors? Windows 7 32bit Is it possible to sort cells in shades of colors? Office 2013
Novice
Is it possible to sort cells in shades of colors?
 
Join Date: Apr 2013
Posts: 8
Kreol2013 is on a distinguished road
Default

rainbow but still does not work, will have his hands still do everything.
Reply With Quote
  #8  
Old 02-08-2014, 04:02 PM
excelledsoftware excelledsoftware is offline Is it possible to sort cells in shades of colors? Windows 7 64bit Is it possible to sort cells in shades of colors? Office 2003
IT Specialist
 
Join Date: Jan 2012
Location: Utah
Posts: 455
excelledsoftware will become famous soon enough
Default

Quote:
Originally Posted by Kreol2013 View Post
rainbow but still does not work, will have his hands still do everything.
Still? What have you tried that didn't work? I know that the VBA script gives a number you can sort by but maybe you were looking for a different kind of sort. Let us know thanks.
Reply With Quote
  #9  
Old 02-09-2014, 12:44 AM
macropod's Avatar
macropod macropod is offline Is it possible to sort cells in shades of colors? Windows 7 32bit Is it possible to sort cells in shades of colors? Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Kreol2013: Ultimately, this is a question of what constitutes the sorting criteria. Simply say 'by shades of colors' is quite ambiguous. What are your criteria for 'shades of colors'? One could, for example, sort by the R, G or B values in the RGB colour scheme, or by the C, M, Y, K values in the CMYK colour scheme or by the H, S, L values in the HSL colour scheme. You need to work out what your criteria are according to one of these schemes. Compared to C, M, Y, K or H, S, L, it's quite easy to do R, G, B sorts because Excel works in the RGB colour scheme; conversions (for which algorithms are available) would be required for the others. Using the RGB colour scheme, for example, you could sort by Red, Green or Blue intensity, with one or more of the others as a secondary/tertiary criterion, each in ascending or descending order.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #10  
Old 02-09-2014, 02:38 PM
Kreol2013 Kreol2013 is offline Is it possible to sort cells in shades of colors? Windows 7 32bit Is it possible to sort cells in shades of colors? Office 2013
Novice
Is it possible to sort cells in shades of colors?
 
Join Date: Apr 2013
Posts: 8
Kreol2013 is on a distinguished road
Wink

Hi!
Yes, eventually I stopped on the circuit HSV
Hue sorting ascending
Value sorting ascending
Sat sorting descending
Thank you

sample code:
Code:
Sub test()
    For i = 2 To 5000
        sHexVal = Cells(i, 5).Value
        If (sHexVal <> "") Then
Call RGBtoHSV(Cells(i, 6).Value, Cells(i, 7).Value, Cells(i, 8).Value, i)
        End If
    Next i
End Sub

Sub RGBtoHSV(Red, Green, Blue, y)
    Dim min As Double, max As Double, delta As Double
    If Red <= Green And Red <= Blue Then min = Red
    If Green <= Red And Green <= Blue Then min = Green
    If Blue <= Red And Blue <= Green Then min = Blue
    
    If Red >= Green And Red >= Blue Then max = Red
    If Green >= Red And Green >= Blue Then max = Green
    If Blue >= Red And Blue >= Green Then max = Blue
    
    Value = max
    delta = max - min
    
    If Not delta = 0 Then
        Sat = delta / max
    Else
        Sat = 0
        Hue = 0
        Cells(y, 9).Value = Sat
        Cells(y, 10).Value = Hue
        Cells(y, 11).Value = Value
        Exit Sub
    End If
    
    If Red = max Then
        Hue = (Green - Blue) / delta
    ElseIf Green = max Then
        Hue = 2 + (Blue - Red)
    Else
        Hue = 4 + (Red - Green) / delta
    End If
    Hue = Hue * 60
    If Hue < 0 Then Hue = Hue + 360
        Cells(y, 9).Value = Sat
        Cells(y, 10).Value = Hue
        Cells(y, 11).Value = Value
End Sub
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Is it possible to sort cells in shades of colors? How to Sort Table Cells from Left to Right tamaracklodge Word Tables 4 03-04-2013 04:00 AM
Is it possible to sort cells in shades of colors? Unable to change font colors from theme colors choy Word 3 08-01-2012 09:12 PM
Is it possible to sort cells in shades of colors? Auto Colors in Cells? Learner7 Excel 5 07-06-2010 10:55 PM
How can I change the colors of cells automatically based on Job Completion? Learner7 Excel 0 07-06-2010 10:47 PM
Count range cells eliminating merge cells danbenedek Excel 0 06-15-2010 12:40 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 03:11 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft