j l

j l

  • NA
  • 59
  • 0

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

Feb 22 2010 5:54 AM
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)