Jump to content

Excel VBA: Cell Background Color


Recommended Posts

Posted

Excel visual cell background based on RGB value

 

This my use for it,

image.thumb.png.0f9ad360c6f91a7e6599e9d47b8d135d.png

 

 

Function bgRGB(r, g, b)
    Dim clr As Long, src As Range, sht As String, f, v
    If IsEmpty(r) Or IsEmpty(g) Or IsEmpty(b) Then
        clr = vbWhite
    Else
        clr = RGB(r, g, b)
    End If
    Set src = Application.ThisCell
    sht = src.Parent.Name
    f = "Changeit(""" & sht & """,""" & _
                  src.Address(False, False) & """," & clr & ")"
    src.Parent.Evaluate f
    bgRGB = ""
End Function

 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...