My Excel conditional formatting formula works manually but not coded in VBA -


i created formula manually in "conditional formatting" graphic interface

=if(and($m7<>""specificdeparment"",not(isblank($o7))),true) 

it should validate 1 department accepts id, others must not have id, filling error id cell red, worked fine manually, replaced formulas rc format

=if(and(rc[-2]<>""specificdeparment"",not(isblank(rc))),true) 

it runs , makes no difference worksheet, if let 1 condition (example: =if($rc[-2]<>""specificdeparment"",true) works , changes column fill color.

here code use assigning format in vba:

with .range(wrkbook.sheets("data").cells(firstrow, .range("id_marker").column), wrkbook.sheets("data").cells(lastrow, .range("id_marker").column))   .formatconditions.add type:=xlexpression, formula1:="=if(and(rc[-2]<>""specificdeparment"",not(isblank(rc))),true)"      .formatconditions(.formatconditions.count).setfirstpriority        .formatconditions(1)         .font.colorindex = mustfixdatafontcolor             .font.bold = mustfixdatafontbold             .interior.colorindex = 3             .stopiftrue = false         end     end         doevents 

the formula on top excel formula, formula below code produced when vba formula put msgbox

formula comparison


Comments

Popular posts from this blog

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

angular2 services - Angular 2 RC 4 Http post not firing -