View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Dick Kusleika[_4_] Dick Kusleika[_4_] is offline
external usenet poster
 
Posts: 595
Default EZ ??? - Conditional Formatting

m

Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, _
Formula1:= TEXT COLUMN DATA <<< ---- NEED HELP HERE, I THINK
Selection.FormatConditions(2).Interior.ColorIndex = 7

I have two conditions in which I need to color code the DATE COLUMN:
1.) in between s_current & s_future
2.) if the value of the corresponding cell in TEXT COLUMN is "IN"


If you're selecting R:R, the R1 is the active cell and any relative formulas
should be written relative to that cell. Here's an example where you select
R1, but don't select the whole column. I couldn't tell from your example if
you were coloring them different or what, so you may need to adjust.

Sub AddFC()

Dim s_current As String, s_future As String

s_current = Format(DateSerial(Year(Date), Month(Date), 1), "yyyy-mm")
s_future = Format(DateSerial(Year(Date), Month(Date) + 2, 1), "yyyy-mm")

Sheet1.Range("R1").Select

With Sheet1.Range("R:R")
With .FormatConditions.Add(xlCellValue, xlBetween, s_current,
s_future)
.Interior.ColorIndex = 3
End With
With .FormatConditions.Add(xlExpression, , "=$E1=""IN""")
.Interior.ColorIndex = 7
End With
End With

End Sub

--
Dick Kusleika
MS MVP - Excel
www.dailydoseofexcel.com