InvertColor

Converts color into its negative value, as in "e4f15a" into "1C0FA6"

CodeFunctionName
What is this?

Public

Tested

Original Work
Function InvertColor(ColorHex)
    ' Needs Hex2Dec and Dec2Hex
    ' Converts "e4f15a" to "1C0FA6"
    ' Needs Dec2Hex and Hex2Dec below
    ' If ColorHex = "" Then Exit function
    C1                         = ColorHex
    If Len(ColorHex) = 3 Then
        C1                     = Left(C1,1) & Left(C1,1) & Mid(C1,2,1) & Mid(C1,2,1) & Right(C1,1) & Right(C1,1)
    End If
    NC1                         = Right(Dec2Hex(abs(256 - clng(Hex2Dec(Left(C1,2))))),2)
    NC2                         = Right(Dec2Hex(abs(256 - clng(Hex2Dec(Mid(C1,3,2))))),2)
    NC3                         = Right(Dec2Hex(abs(256 - clng(Hex2Dec(Right(C1,2))))),2)
    InvertColor             = NC1 & NC2 & NC3
End Function

ColorHex

Views 4,215

Downloads 1,353

CodeID
DB ID