FONT.COLOR returns NULL in conditional formatting excel vba -
i have sub routine gets conditional formatting properties cell cell in sheet "source" , applies them in sheet "result" in same workbook. works when font.color , font.tintandshade returns null, in result sheet conditional formatting have black font color. (you can check in result sheet conditional formatting > mange rules).
the error "invalid use of null" maybe because of type of values.
error occurs here:
fcfontc = xarr(i, j).formatconditions(ii).font.color fcfontt = xarr(i, j).formatconditions(ii).font.tintandshade
here code:
sub formatcondition1() dim fc formatcondition dim fcfontc long dim fcfontt integer dim fcc long dim fct integer dim ii integer dim wks1 worksheet, wks2 worksheet dim xarr range, yarr range dim integer, j integer 'dim k integer, l integer worksheets("source").activate worksheets("result").select set yarr = worksheets("result").range("a1:c2") yarr.range("a1:c2").clear set wks1 = activeworkbook.worksheets("source") set wks2 = activeworkbook.worksheets("result") set xarr = wks1.range("a1:c2") set yarr = wks2.range("a1:c2") = 1 xarr.rows.count j = 1 xarr.columns.count if xarr(i, j).formatconditions.count > 0 ii = 1 xarr(i, j).formatconditions.count 'ii number of conditions set fc = xarr(i, j).formatconditions.item(ii) 'cell font formatting '**** error here ******* fcfontc = xarr(i, j).formatconditions(ii).font.color fcfontt = xarr(i, j).formatconditions(ii).font.tintandshade 'cell interior formating 'set fccin = xarr.formatconditions(ii).interior.patterncolorindex fcc = xarr(i, j).formatconditions(ii).interior.color fct = xarr(i, j).formatconditions(ii).interior.tintandshade 'set property new cell yarr(i, j).select selection.formatconditions.add type:=xlcellvalue, operator:= _ fc.operator, formula1:=fc.formula1 'selection.formatconditions(selection.formatconditions.count).setfirstpriority 'cell font formatting selection.formatconditions(ii).font.color = fcfontc selection.formatconditions(ii).font.tintandshade = fcfontt 'cell interior formating selection.formatconditions(ii).interior .patterncolorindex = xlautomatic .color = fcc .tintandshade = fct end selection.formatconditions(selection.formatconditions.count).stopiftrue = false next ii end if next j next
end sub
my question "how can property of conditional formatting fonts also?
Comments
Post a Comment