Dynamic interior colors

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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?
 
Since it's only 3 conditions, you could use conditional formatting from
Format-Conditional Formatting.
 
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" <[email protected]>
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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top