excel - Return the list of colored cells based on certain conditions -
i have in sheet1
:
and in sheet2
want lookup , filter colored data, , result be:
goal: return list of colored cells
filtering (lookup) conditions:
1. return colored cell (copy/paste exact cell content) columns j to v from sheet1
same cell references in sheet2
. (the color filled in color)
2.for each colored cell in specified range, return cells columns e, h , and i.
3. ignore cells (whether colored or not), content equal to *na* (asterisk na asterisk).
the number of rows 10000+ number of colored cells not exceed 500.
vba code preferred, if can done formulas, acceptable.
here example sheet ease of copy pasting.
update
the cells colored conditional formatting rules in sheet1
. grominet's answer working cells manually colored. how take account conditional formatting colors?
i suggest loop every lines, , test every columns criteria (not na , colored). if true, copy colored cell. , add header line.
here start code working, need adapt reach goal.
sub test() dim aline long dim acolumn long dim lastlines2 long 'lastline of sheet2 dim test boolean lastlines2 = 3 aline = 3 100 test = false acolumn = 1 50 if acolumn > 9 , acolumn < 22 if sheets("sheet1").cells(aline, acolumn).value <> "*na*" , sheets("sheet1").cells(aline, acolumn).interior.pattern <> xlnone sheets("sheet2").cells(lastlines2, acolumn) = sheets("sheet1").cells(aline, acolumn) test = true end if end if next acolumn if test 'copy line heading acolumn = 1 9 sheets("sheet2").cells(lastlines2, acolumn) = sheets("sheet1").cells(aline, acolumn) next acolumn lastlines2 = lastlines2 + 1 end if next aline end sub
Comments
Post a Comment