UDF Warna RGB Cells

Sebuah User Defined Function untuk mendapatkan Nilai RGB dari warna Cells

Function getWarnaRGB(Rng As Range) As String
'-----------------------------------------
' Sctipt VBA    : 7a (Warna RGB A)
' Author        : https://vba.co.id
'                 Situs belajar VBA No.1
'                 di Indonesia
'-----------------------------------------
Dim hexColor As String
hexColor = Right("000000" & Hex(Rng.Interior.Color), 6)
getWarnaRGB = "RGB (" & CInt("&H" & Right(hexColor, 2)) & "," & _
                        CInt("&H" & Mid(hexColor, 3, 2)) & "," & _
                        CInt("&H" & Left(hexColor, 2)) & ")"
                    
End Function

Cara kedua

Function getWarnaRGB(Rng As Range) As String
'-----------------------------------------
' Sctipt VBA    : 7b (Warna RGB B)
' Author        : https://vba.co.id
'                 Situs belajar VBA No.1
'                 di Indonesia
'-----------------------------------------
Dim hexColor As Long
hexColor = Rng.Interior.Color
getWarnaRGB = "RGB (" & hexColor Mod 256 & "," & _
                        (hexColor \ 256) Mod 256 & "," & _
                        (hexColor \ 65536) & ")"
                    
End Function
List Tutorial
Apa yang sedang kamu cari?

Temukan beberapa kata kunci yang diinginkan.

Search