Last active
May 16, 2024 00:49
-
-
Save tomfleet/53c18a1ae8a69ed8c4dcec6cd460c871 to your computer and use it in GitHub Desktop.
Colour your excel cell backgrounds based on values.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Public Function myRGB(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 | |
| myRGB = "" | |
| End Function | |
| Sub ChangeIt(sht, c, clr As Long) | |
| ThisWorkbook.Sheets(sht).Range(c).Interior.Color = clr | |
| End Sub | |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I throw this in an excel workbook VB module, then just "=myRGB(uin8_t r, uint8_t g, uint8_t b)" in a cell.
ex