Hello and thanks for your help,
Right now I have a data sheet that is updated from SQL so the number of rows change when it is updated. Also, Rows are automatically highlighted yellow if cell $O4 = 1 and Rows where $E4 <= $E$2 are automatically highlighted blue. And I am trying to delete the format where the rows are highlighted blue. But If I were to manual type in 1 in one of the cells in column O, I would like that row to highlight yellow and follow the previous condition. And I would like this is VBA. I know I can go into Conditional Formatting and change it that way. But I would like to run a macro to do this.
Here is what I have:
Sub Clear_Cond_Formatting()
Dim rng As Range
Dim a As Long
Select Case Selection.Cells.Count
Case 1
Set rng = Cells
Case Else
Set rng = Selection
End Select
On Error Resume Next
rng.FormatConditions.Delete
For a = 4 To Range("E65536").End(xlUp).Row
If Range("$o4") <> 1 Then
Rows(a).Interior.ColorIndex = 4
End If
Next a
On Error GoTo 0
MsgBox "complete"
End Sub
Right now it is highlighting the whole table. It seems like it isnt reading the value in row O.
Sorry if it is confusing.
Right now I have a data sheet that is updated from SQL so the number of rows change when it is updated. Also, Rows are automatically highlighted yellow if cell $O4 = 1 and Rows where $E4 <= $E$2 are automatically highlighted blue. And I am trying to delete the format where the rows are highlighted blue. But If I were to manual type in 1 in one of the cells in column O, I would like that row to highlight yellow and follow the previous condition. And I would like this is VBA. I know I can go into Conditional Formatting and change it that way. But I would like to run a macro to do this.
Here is what I have:
Sub Clear_Cond_Formatting()
Dim rng As Range
Dim a As Long
Select Case Selection.Cells.Count
Case 1
Set rng = Cells
Case Else
Set rng = Selection
End Select
On Error Resume Next
rng.FormatConditions.Delete
For a = 4 To Range("E65536").End(xlUp).Row
If Range("$o4") <> 1 Then
Rows(a).Interior.ColorIndex = 4
End If
Next a
On Error GoTo 0
MsgBox "complete"
End Sub
Right now it is highlighting the whole table. It seems like it isnt reading the value in row O.
Sorry if it is confusing.