I'm trying to add conditional formatting to my VSTO Excel C# Application. I want to set the cell background colour to red if the column value in AH is the same as the column value in X and if X is not blank. However it complains at the below code saying
Syntax error ',' expected.
This formula works fine when I manually put it in excel.
This is my formula: =AND(X7=AH7,X7<>"")
And here's my C# code:
FormatCondition format7 =
(FormatCondition)(uiWorksheet.get_Range("AH7:AH" + lastUsedRow, Type.Missing)
.FormatConditions.Add(XlFormatConditionType.xlExpression,
XlFormatConditionOperator.xlEqual, "=AND(X7=AH7,X7<>"")",
Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing));
format7.Interior.Color = System.Drawing.Color.Red;