vba I have used the below code to insert conditional formatting in an excel cell..
range("d" & rowno).Select
Selection.Offset(1, 0).EntireRow.Insert
Selection.FormatConditions.Add Type:=xlExpression, Formula1:="= RC > 7"
Selection.FormatConditions(Selection.FormatConditions.count).SetFirstPriority
With Selection.FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.Color = 65535 'Yellow
.TintAndShade = 0
End With
The above works fine by comparing the grater than value defined which is "7"...
But if i pass variable "lhigh" in which value is stored and the same im passing it in the formaula it does not works.
e.g;
lhigh=7
range("d" & rowno).Select
Selection.Offset(1, 0).EntireRow.Insert
Selection.FormatConditions.Add Type:=xlExpression, Formula1:="= RC > lhigh"
Selection.FormatConditions(Selection.FormatConditions.count).SetFirstPriority
With Selection.FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.Color = 65535 'Yellow
.TintAndShade = 0
End With
Please let me know how we can than calculate greater than check if we pass variable instead of direct integer value