6
Reply

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

Ask a question
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)