Public Sub color_cells()
Dim data_range As Range
Set data_range = Range("F2:G21") ' Change as required
data_range.Interior.ColorIndex = 0
selected_date = ActiveCell.Offset(0, 1).Value
ActiveCell.Interior.ColorIndex = 8
ActiveCell.Offset(0, 1).Interior.ColorIndex = 8
data_range.Select
number_of_rows = Selection.Rows.Count
For i = 1 To number_of_rows
If ActiveCell.Offset(i - 1, 1).Value < selected_date Then
ActiveCell.Offset(i - 1, 1).Interior.ColorIndex = 6
End If
Next
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Column = 2 Then Calculate
End Sub[/pre]
then select the column with Date value and use the below condition formatting..
=$B2>OFFSET($B$1,CELL("row"),0)
Public Sub color_cells()
Dim data_range As Range
Set data_range = Range("A2:F21") ' Change as required
data_range.Interior.ColorIndex = 0
selected_date = ActiveCell.Offset(0, -5).Value
ActiveCell.Interior.ColorIndex = 8
ActiveCell.Offset(0, -5).Interior.ColorIndex = 8
data_range.Select
number_of_rows = Selection.Rows.Count
For i = 1 To number_of_rows
If ActiveCell.Offset(i - 1, 0).Value < selected_date Then
ActiveCell.Offset(i - 1, 0).Interior.ColorIndex = 6
End If
Next
End Sub
=AND($B2>OFFSET($B$1,CELL("row")-1,0),NOT($K2=$Y2))
Public Sub color_cells()
Dim data_range As Range
Set data_range = Range("A2:F21") ' Change as required
data_range.Interior.ColorIndex = 0
selected_date = ActiveCell.Offset(0, -5).Value ' -5 is because column A is 5 columns to the left of column F
ActiveCell.Interior.ColorIndex = 8
ActiveCell.Offset(0, -5).Interior.ColorIndex = 8 ' -5 is because column A is 5 columns to the left of column F
data_range.Select
number_of_rows = Selection.Rows.Count
For i = 1 To number_of_rows
' 10 is because column K is 10 columns to the right of column A
' If column K cells will need to be checked for any character other than Y
' change the next statement to reflect this.
If ((ActiveCell.Offset(i - 1, 0).Value < selected_date) And (UCase(ActiveCell.Offset(i - 1, 10).Value) <> "Y")) Then
ActiveCell.Offset(i - 1, 0).Interior.ColorIndex = 6
End If
Next
End Sub