ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Specific Conditional Selection (https://www.excelbanter.com/excel-programming/372406-specific-conditional-selection.html)

mvyvoda

Specific Conditional Selection
 
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

Nigel

Specific Conditional Selection
 
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

--
Cheers
Nigel



"mvyvoda" wrote in message
...
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





All times are GMT +1. The time now is 01:29 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com