excel - Store range of color values as array in VBA -


i want color values table in excel, store them array while reorganize table, , put color values table. following code works values , number formats not color values. appreciated.

sub colors()     dim carray variant     set rng = range("a1: t300")     redim carray(1 rng.rows.count, 1 rng.columns.count)     = 1 rng.rows.count         j = 1 rng.columns.count             carray(i, j) = rng(i, j).colorvalue         next j     next     call sorttable     rng.colorvalue = carray end sub 

i'm not sure .colorvalue recognized vba. instead, use carray(i,j) = rng(i,j).interior.colorindex.

then, when want set cell's color, cells(1,1).interior.colorindex = [whatever].

here's a pretty detailed page discussing colorindex , html/hex/rgb equivalents/related things.

edit: assumed wanted background color. if instead want font color, it'd carray(i,j) = rng(i,j).font.color.


Comments

Popular posts from this blog

html - Firefox flex bug applied to buttons? -

html - Missing border-right in select on Firefox -

c# - two queries in same method -