• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Color identification in excel

SAN04

Member
Hello all,

I need to assign particular number (1,2,3&4) based on the color in particular cell. Example if cell is colored yellow, the number 1 should come in cell, if cell is colored red, the number 2 should come in the cell.

Please suggest formula for the same.

Regards
Sanjay Dixit
 
Thanks sili12 but my query is different. I am uploading the sheet with along with the query. Please help.
 

Attachments

  • Query.xlsx
    9.2 KB · Views: 2
SAN04
You skipped to explain - how those colors would 'come' to those cells?
This shows those numbers after You'll move away from cell.
 

Attachments

  • Query.xlsb
    15 KB · Views: 5
Thanks Vletm.

Please tell how you did that else I have to further use various colors and numbers.
 
SAN04
Check that code.
Add there more case's as You would like...
Code:
            Select Case .Interior.Color
                Case 65535
                    c = 1
                Case 255
                    c = 2
                Case 5287936
                    c = 3
                Case 15773696
                    c = 4
            End Select
 
Thanks Vltem. Please tell how this value against is calculated. In case i use now brown color what will be the value.
 
SAN04
... brown ... there are many kind of browns
Test this sample and You'll see needed value from Statusbar
 

Attachments

  • Query.xlsb
    16 KB · Views: 5
SAN04
There is none that kind of formula ...
Application.StatusBar = ActiveCell.Interior.Color

If You would like to solve those ... then ... eg
Get RGB-values
Screenshot 2022-09-08 at 17.59.02.png
and
calculate that value with below
Code:
Function xlfRGB2DecX(Red As Integer, Green As Integer, Blue As Integer) As Long
    xlfRGB2DecX = Red * 256 ^ 0 + Green * 256 ^ 1 + Blue * 256 ^ 2
End Function
 
Back
Top