excel vba - VBA Conditional Formatting if Cell Not Between -


i need apply conditional formatting cell using vbscript change background color of cell if it's value not between value of 2 other cells:

picture of excel dialog

code macro

selection.formatconditions.add type:=xlcellvalue, operator:=xlnotbetween, _     formula1:="=$i$28", formula2:="=$j$28" selection.formatconditions(selection.formatconditions.count).setfirstpriority selection.formatconditions(1).interior     .patterncolorindex = xlautomatic     .color = 255     .tintandshade = 0 end selection.formatconditions(1).stopiftrue = false end sub 

my conversion vbscript isn't working

    pricerange = "k"&rownum + 2     objworksheet.range(pricerange).formatconditions.add type:=1, operator:=2, formula1:="=$i$"&finalrownum + 1&"", formula2:="=$j$"&finalrownum + 1&""     objworksheet.range(pricerange).formatconditions(objexcel.selection.formatconditions.count).setfirstpriority     objworksheet.range(pricerange).formatconditions(1).interior.patterncolorindex = -4105     objworksheet.range(pricerange).formatconditions(1).interior.color = 255     objworksheet.range(pricerange).formatconditions(1).interior.tintandshade = 0     objworksheet.range(pricerange).formatconditions(1).stopiftrue = false 

the code worked

set rng = objworksheet.range("k" & rownum + 2)  'vbscript doesn't support named arguments, positional set fc = rng.formatconditions.add(1, 2, _                                  "=$i$" & finalrownum, _                                  "=$j$" & finalrownum) fc.setfirstpriority  fc.interior     .patterncolorindex = -4105     .color = 255     .tintandshade = 0 end  fc.stopiftrue = false 

Comments

Popular posts from this blog

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - UML - How would you draw a try catch in a sequence diagram? -

c++ - No viable overloaded operator for references a map -