Cells background color according to 3 cells data NOT CONDITIONAL FORMATTING

KDS14589

Board Regular
Joined
Jan 10, 2019
Messages
182
Office Version
  1. 2016
Platform
  1. Windows
I have 4 cells. B2 is R, C2 is G, D2 is B, those represent the color palate. Under those cells are cells B3,C3,D3 that I've data restricted to numbers between 0-255. I want cell E3 to have the color reflected by the numbers I've entered in the first three cells. If I change the numbers in those cells I want the color of cell E3 to change to. I've included an image of what I'm attempting. I know it involves VBA but I don't know were to start or even where to start looking.
color.png
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
Put code in SHEET code window
- right click on sheet tab\ View Code \ paste code into the window on the right
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    On Error Resume Next
    Dim R As Integer, G As Integer, B As Integer
    R = [B3]
    B = [C3]
    G = [D3]
    If Not Intersect(Target, Range("B3:D3")) Is Nothing Then Range("E3").Interior.Color = RGB(R, G, B)
    On Error GoTo 0
End Sub
 
Upvote 0
OOPS :eek:

Rich (BB code):
Private Sub Worksheet_Change(ByVal Target As Range)
    On Error Resume Next
    Dim R As Integer, G As Integer, B As Integer
    R = [B3]
    G = [C3]
    B = [D3]
    If Not Intersect(Target, Range("B3:D3")) Is Nothing Then Range("E3").Interior.Color = RGB(R, G, B)
    On Error GoTo 0
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,983
Messages
6,122,592
Members
449,089
Latest member
Motoracer88

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top