View Single Post
 
Old 05-10-2018, 10:30 PM
jolivanes jolivanes is offline Windows 10 Office 2013
Advanced Beginner
 
Join Date: Sep 2011
Posts: 91
jolivanes will become famous soon enough
Default

If need be, you can get the RGB values with this.
Select a colored cell and run this code. Use this in the "Maybe_With_RGB()" macro
Code:
Sub ShowColour()
    Dim RGBColour As String, R As Integer, G As Integer, B As Integer, c As Range
        RGBColour = Right("000000" & Hex(Selection.Interior.Color), 6)
            R = WorksheetFunction.Hex2Dec(Right(RGBColour, 2))
            G = WorksheetFunction.Hex2Dec(Mid(RGBColour, 3, 2))
            B = WorksheetFunction.Hex2Dec(Left(RGBColour, 2))
        MsgBox "RGB(" & R & ", " & G & ", " & B & ")"
End Sub
Code to fill with numbers
Code:
Sub Maybe_With_RGB()
Dim c As Range
For Each c In Range("A1:D12")    '<----- Change to actual used colored range
    With c
        Select Case .Interior.Color
            Case Is = RGB(255, 0, 0)    '<----- Change to what you get for Red
                c.Value = -1
                    Case Is = RGB(0, 255, 0)    '<----- Change to what you get for Green
                        c.Value = 1
                    Case Is = RGB(255, 255, 0)    '<----- Change to what you get for Yellow
                c.Value = 0
            Case Else
        End Select
    End With
Next c
End Sub
Reply With Quote