Specific Conditional Selection

M

mvyvoda

Perceived Question:
I need to set a constant to a specific value (the string "IN") in a specific
column. I am working with conditional formatting and one of the conditions is
if the constant is "IN" then the formatting will take place, else no
formatting. Here's what I have so far:

Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlBetween, _
Formula1:=s_current, Formula2:=s_future
Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, _
Formula1:= CONSTANT THAT EQUALS "IN"
Selection.FormatConditions(1).Interior.ColorIndex = 3

Where I place CONSTANT THAT EQUALS "IN" is, obviously, the value in the
specific column.

I hope I am making myself clear and need help badly. I appreciate any time
and consideration you may provide. As usual, I always get help from you
guys/gals!!!

Thanks,
-m
 
N

Nigel

If I understand your question then you wish to test a condition based on a
value (Constant) within your code. You could use the following, clearly the
value of xConst will always be TRUE in this method, but if some other code
you have is changing this value then referencing the value set works OK

' declare this in your set up module
Public xConst As String
xConst = "IN"


' your code to set conditions on sheet
Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlBetween, _
Formula1:=s_current, Formula2:=s_future
Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, _
Formula1:=xConst
Selection.FormatConditions(1).Interior.ColorIndex = 3
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top