Create function Color
How would create a function that would call "color" using this code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim A As Integer
Dim B As Integer
Dim C As Integer
A = Range("a1").Value
B = Range("b1").Value
C = Range("c1").Value
Range("D1").Interior.Color = RGB(A, B, C)
End Sub
Ok, I get it!
Sorry, i did not understand that before.
Then here you have the function:
Function color(a, b, c)
Selection.Interior.color = RGB(a, b, c)
End Function
But i am not sure if you will be able to drag it once that it does not return a value, just execute something.
Change color Cell D1
I am not exactly sure about what do you want, but if you want to paint the D1 cell with the specifications given by the values on cells a1, b1 and c1. You can use this code:
Option Explicit
Sub color()
Dim A As Integer
Dim B As Integer
Dim C As Integer
A = Range("A1").Value
B = Range("B1").Value
C = Range("C1").Value
Range("D1").Interior.color = RGB(A, B, C)
End Sub
I hope it helps,
Cátia Santos
This code is only for the
This code is only for the cell d1, really, I want to drag the cell to other cells .
For example I will set, data a1, b1, c1, then a2, b2, c2, then a3, b3, c3 and so on, I will not write codes for each cell(d1,d2,d3,d4,d5,d6,....dn), but with a function, drag from one cell, I want to create the function =color(,,)for RGB.