Hello,
I have the following code:
It scans the range (A1:A40) for keyword "pH", then applies cond. formatting to the entirerow.
When I only use 1 condition, the range selected ends at the last column of entered data. However, when I use both conditions, the formatting is applied to the entire row.
I've tried swapping .EntireRow for .End(xlright) but in this case the formatting is not applied whatsoever.
Any help would be greatly appreciated.
I have the following code:
Code:
On Error Resume Next
xpH = Application.WorksheetFunction.Match("pH", Range("A1:A40"), 0)
Dim rngToFormat11 As Range
Set rngToFormat11 = ActiveSheet.Rows(xpH).EntireRow
'first, clear any old Cond format for these cells
rngToFormat11.FormatConditions.Delete
'add cond 1
rngToFormat11.FormatConditions.Add Type:=xlCellValue, _
Operator:=xlGreater, Formula1:="=8.5"
rngToFormat11.FormatConditions(1).Interior.Color = 65535
'add cond 2
rngToFormat11.FormatConditions.Add Type:=xlCellValue, _
Operator:=xlLess, Formula1:="=6.5”
rngToFormat11.FormatConditions(2).Interior.Color = 65535
It scans the range (A1:A40) for keyword "pH", then applies cond. formatting to the entirerow.
When I only use 1 condition, the range selected ends at the last column of entered data. However, when I use both conditions, the formatting is applied to the entire row.
I've tried swapping .EntireRow for .End(xlright) but in this case the formatting is not applied whatsoever.
Any help would be greatly appreciated.