ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Dynamic interior colors (https://www.excelbanter.com/excel-programming/389278-dynamic-interior-colors.html)

robl

Dynamic interior colors
 
This is probably a simple answer, but I cannot see it.

I have four cells, A1, B1, C1 and D1. What I would like to do is to have a
funtion so that when values are entered into A1(Red), B1(Green), and
C1(Blue), the interior color of D1 would correspond to the RGB values
entered.

Is there such a beast where I could type into cell D1, =RGB(A1, B1, C1) ?
If not how would I go about creating such a function?


PCLIVE

Dynamic interior colors
 
Since it's only 3 conditions, you could use conditional formatting from
Format-Conditional Formatting.


"RobL" wrote in message
...
This is probably a simple answer, but I cannot see it.

I have four cells, A1, B1, C1 and D1. What I would like to do is to have
a
funtion so that when values are entered into A1(Red), B1(Green), and
C1(Blue), the interior color of D1 would correspond to the RGB values
entered.

Is there such a beast where I could type into cell D1, =RGB(A1, B1, C1) ?
If not how would I go about creating such a function?




Jim Cone

Dynamic interior colors
 

Cell D1 will display the rgb color if you enter integers in A1, B1, C1.
Place this code in the Sheet module...
'--
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
If Not Intersect(Target(1, 1), Me.Range("A1:C1")) Is Nothing Then
Dim N As Long
For N = 1 To 3
If Not IsNumeric(Me.Cells(1, N)) Then Exit Sub
Next
Me.Parent.Colors(54) = _
RGB(Me.Range("A1").Value, Me.Range("B1").Value, Me.Range("C1").Value)
Me.Range("D1").Interior.ColorIndex = 54
End If
End Sub
'--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware



"RobL"
wrote in message
This is probably a simple answer, but I cannot see it.
I have four cells, A1, B1, C1 and D1. What I would like to do is to have a
funtion so that when values are entered into A1(Red), B1(Green), and
C1(Blue), the interior color of D1 would correspond to the RGB values
entered.
Is there such a beast where I could type into cell D1, =RGB(A1, B1, C1) ?
If not how would I go about creating such a function?



All times are GMT +1. The time now is 11:51 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com