View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Toppers Toppers is offline
external usenet poster
 
Posts: 4,339
Default How dio I attach a variable to an Operator:= ?

Richard,
This works (or you set Opval to 6 = xlLess/ 5 = XlGreater))
opVal = xlLess

With rMyrange.FormatConditions
.Add Type:=xlCellValue, Operator:=opVal, Formula1:=sRed
.Add Type:=xlCellValue, Operator:=xlLess, Formula1:=sOrange
.Add Type:=xlCellValue, Operator:=xlGreater, Formula1:=sGreen
End With


HTH

"Richard Buttrey" wrote:

Hi,

I have within a procedure the following code. I set the variables
sRed, SOrange etc. earlier in the procedure, and would also like to
set the Operator:= blah, blah as a variable. I've tried passing it as
a string and variant variable but to no avail.

Can anyone help me out please?

i.e how can I get the bit following the Operator:= to recognise a
variable.?

Usual TIA.

With rMyrange.FormatConditions
.Add Type:=xlCellValue, Operator:=xlLess, Formula1:=sRed
.Add Type:=xlCellValue, Operator:=xlLess,Formula1:=sOrange
.Add Type:=xlCellValue, Operator:=xlGreater, Formula1:=sGreen
End With

__
Richard Buttrey
Grappenhall, Cheshire, UK
__________________________