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 

Comments
Post a Comment