Search

Get RBG Color Code from Color Number of Sheet, Cell, Shapes and more...


Convert tab color for example from 24704 to  RGB Code R=128 ,G=  96 ,B= 0

Option Explicit

Sub tabRGB()

Dim j As Worksheet
Set j = ActiveSheet

Dim f As Variant
f = ConvertCode2RGB(j.Tab.Color)

Debug.Print j.Tab.Color

Debug.Print f(1)
Debug.Print f(2)
Debug.Print f(3)

Set j = Nothing

End Sub

Function ConvertCode2RGB(colorNo) As Variant

'-----------------------------
'Thanks for downloading the code. 
'Please visit our channel for a quick explainer on this code.
'Feel free to update the code as per your need and also share with your friends.
'Channel: Youtube.com/vbaa2z
'Download free codes from http://vbaa2z.blogspot.com
'Autor: L Pamai (vbaa2z.team@gmail.com)
'-----------------------------

    Dim xR As Long, xG As Long, xB As Long
    Dim k(1 To 3) As Variant
    
    xR = colorNo Mod 256
    xG = colorNo \ 256 Mod 256
    xB = colorNo \ 65536 Mod 256
    
    k(1) = xR
    k(2) = xG
    k(3) = xB
    
    ConvertCode2RGB = k()
    
End Function

No comments:

Post a Comment

Note: only a member of this blog may post a comment.