excel - Assign cell background color to rgb from referenced cells -


i'm working in excel on programatically setting cell's background color specific rgb color referenced in nearby cells. here's i'm trying do:

enter image description here

you can see manually set background color rgb values specified in cells in same row on left, highlighted in picture. first purple cell has rgb (148,91,128).

i want in vba or maybe conditional formatting if possible. far have tried simple vba line of code see if work:

range("f1").interior.color = rgb(c1, d1, e1) 

however line of code sets cell have black background this:

enter image description here

if code had worked correctly, cell should have been white color, not black. ideas on why isn't working? making mistake way reference cells rgb?

it nice able assign range "f1:f__" reference cells left on each row too, not 1 cell. thanks!

try this:

range("f1").interior.color = rgb(range("c1"), range("d1"), range("e1")) 

in version of code c1, d1, e1 taken variables , have default value 0, macro assign color equal rgb(0, 0, 0) black.


Comments

Popular posts from this blog

Fail to load namespace Spring Security http://www.springframework.org/security/tags -

sql - MySQL query optimization using coalesce -

unity3d - Unity local avoidance in user created world -