excel - get value from specific background -


i have list background colors in "a" column , value in ceil name of colors. want when select cell background color change value of "c1" value value have in "a" column.
(this not real name of colors, have specific name each colors.) vlookup background colors , in same ceil.
example: enter image description here

thank you!

put in code section of worksheet :

private sub worksheet_selectionchange(byval target range)     target         if dictcolours.exists(.interior.colorindex)             sheets("sheet1").range("c1").value = dictcolours(.interior.colorindex)         end if     end end sub 

and add new module, replacing sheet reference:

public dictcolours scripting.dictionary  sub test()     set dictcolours = new scripting.dictionary      dim rngtarget range     set rngtarget = sheets("sheet1").range("a1")      while rngtarget.value <> ""         dictcolours.add rngtarget.interior.colorindex, rngtarget.value         set rngtarget = rngtarget.offset(1, 0)     loop  end sub 

Comments