6
Answers

How do I change the color of a cell in Excel based on a Condition?

j l

j l

14y
8.1k
1
I want to change the color of a cell in Excel bases upon the text in the cell being the value "TRUE"

I tried this statement, but I get an error...can someone help me?

I am using Microsoft.Office.Interop.Excel


if (excelApp.Range[rowIndex, colIndex].Value = "TRUE")
            {
                excelApp.Range[rowIndex, colIndex].Interior.ColorIndex = 4;
            }
            else
            {
                excelApp.Range[rowIndex, colIndex].Interior.ColorIndex = 3;
            }


thanks

J
Answers (6)