Cells background color according to 3 cells data NOT CONDITIONAL FORMATTING

KDS14589

Board Regular
Joined
Jan 10, 2019
Messages
54
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
 

Some videos you may like

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.

Yongle

Well-known Member
Joined
Mar 11, 2015
Messages
6,977
Office Version
  1. 365
Platform
  1. Windows
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
 

Yongle

Well-known Member
Joined
Mar 11, 2015
Messages
6,977
Office Version
  1. 365
Platform
  1. Windows
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
 

Watch MrExcel Video

Forum statistics

Threads
1,127,820
Messages
5,627,092
Members
416,219
Latest member
TommyBoy79

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
Top