Sub SetFormatConditionsExample()
Dim FCRange As Range
Dim FormulaStr As String
Dim WS As Worksheet
Set WS = ActiveSheet
Set FCRange = WS.Range("A2:A100")
With FCRange.FormatConditions
.Delete
FormulaStr = "=AND($A2>20,$A2<50)"
With .Add(Type:=xlExpression, Formula1:=FormulaStr)
.StopIfTrue = True
.Interior.Color = vbGreen
.Font.Color = vbBlack
End With
End With
Set FCRange = WS.Range("B2:B100")
With FCRange.FormatConditions
.Delete
FormulaStr = "=AND($B2>20,$B2<50)"
With .Add(Type:=xlExpression, Formula1:=FormulaStr)
.StopIfTrue = True
.Interior.Color = vbYellow
.Font.Color = vbBlack
End With
End With
End Sub