I'm attempting to get a cell ("L2") to show the RGB color of values I place in Cells H2-I2-J2
Columns H-J are data validation restricted to 0-255 and the range is "H2:J1002"
Cell ("K2") is combined data from H2, I2, J2 and engages only if there are values in ALL three columns.
My worksheet is ShGE03 (I use CodeName so if sheet name is changed it won't affect program)
I have approximately 1000 rows
This code is from an old workbook and is only for one row, but this time it's 1000 rows and I don't want to write it 1000 times and my loops are rudimentary. Help would be appreciated.
Columns H-J are data validation restricted to 0-255 and the range is "H2:J1002"
Cell ("K2") is combined data from H2, I2, J2 and engages only if there are values in ALL three columns.
My worksheet is ShGE03 (I use CodeName so if sheet name is changed it won't affect program)
I have approximately 1000 rows
This code is from an old workbook and is only for one row, but this time it's 1000 rows and I don't want to write it 1000 times and my loops are rudimentary. Help would be appreciated.
Code:
' Sub color()
Dim r As Integer, g As Integer, b As Integer
r = [H2]
g = [I2]
b = [J2]
Range("K2").FormulaR1C1 = "=IF(AND(RC[-3]<>"""",RC[-2]<>"""",RC[-1]<>""""),RC[-3]&"",""&RC[-2]&"",""&RC[-1],"""")"
Range("k2").BorderAround ColorIndex:=1, Weight:=xlThin
Range("l2").Interior.color = RGB(r, g, b)
End Sub
Attachments
Last edited: