Hi,
can you pls help me with improving my VBA code. the goal is to:
- make excel automatically change cell colors in column D, according to RGB values in column A, B and C
- I want it to be automatic - every time you fill cells in columns A:C, cell in column D will change color based on RGB values
- I do not want it to delate date written in cell in column D
I have managed to make below code, however I need to make it for every row separately.
example RGB values:
[TABLE="width: 192"]
<colgroup><col width="64" span="3" style="width:48pt"> </colgroup><tbody>[TR]
[TD="width: 64, align: right"]245[/TD]
[TD="width: 64, align: right"]238[/TD]
[TD="width: 64, align: right"]242[/TD]
[/TR]
[TR]
[TD="align: right"]32[/TD]
[TD="align: right"]4[/TD]
[TD="align: right"]22[/TD]
[/TR]
[TR]
[TD="align: right"]150[/TD]
[TD="align: right"]150[/TD]
[TD="align: right"]149[/TD]
[/TR]
[TR]
[TD="align: right"]253[/TD]
[TD="align: right"]205[/TD]
[TD="align: right"]203[/TD]
[/TR]
[TR]
[TD="align: right"]255[/TD]
[TD="align: right"]150[/TD]
[TD="align: right"]134[/TD]
[/TR]
[TR]
[TD="align: right"]107[/TD]
[TD="align: right"]161[/TD]
[TD="align: right"]104[/TD]
[/TR]
[TR]
[TD="align: right"]203[/TD]
[TD="align: right"]59[/TD]
[TD="align: right"]28[/TD]
[/TR]
</tbody>[/TABLE]
can you pls help me with improving my VBA code. the goal is to:
- make excel automatically change cell colors in column D, according to RGB values in column A, B and C
- I want it to be automatic - every time you fill cells in columns A:C, cell in column D will change color based on RGB values
- I do not want it to delate date written in cell in column D
I have managed to make below code, however I need to make it for every row separately.
Code:
Sub color()
Dim R As Integer, G As Integer, B As Integer
R = ActiveCell.Offset(0, -3).Value
G = ActiveCell.Offset(0, -2).Value
B = ActiveCell.Offset(0, -1).Value
Range("d1:d20").Interior.color = RGB(R, G, B)
End Sub
example RGB values:
[TABLE="width: 192"]
<colgroup><col width="64" span="3" style="width:48pt"> </colgroup><tbody>[TR]
[TD="width: 64, align: right"]245[/TD]
[TD="width: 64, align: right"]238[/TD]
[TD="width: 64, align: right"]242[/TD]
[/TR]
[TR]
[TD="align: right"]32[/TD]
[TD="align: right"]4[/TD]
[TD="align: right"]22[/TD]
[/TR]
[TR]
[TD="align: right"]150[/TD]
[TD="align: right"]150[/TD]
[TD="align: right"]149[/TD]
[/TR]
[TR]
[TD="align: right"]253[/TD]
[TD="align: right"]205[/TD]
[TD="align: right"]203[/TD]
[/TR]
[TR]
[TD="align: right"]255[/TD]
[TD="align: right"]150[/TD]
[TD="align: right"]134[/TD]
[/TR]
[TR]
[TD="align: right"]107[/TD]
[TD="align: right"]161[/TD]
[TD="align: right"]104[/TD]
[/TR]
[TR]
[TD="align: right"]203[/TD]
[TD="align: right"]59[/TD]
[TD="align: right"]28[/TD]
[/TR]
</tbody>[/TABLE]