Hello Im using Visual Studio 2010 beta release.. and Excel Interop library
Let me explain better what I'm trying to do:
If the cell value of A1 is the text "TRUE", then I want to change the cell background of A2 to color GREEN
How do I do this?
J
Change the color of a cell based upon a Condition statement?
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.

Sam HobbsRank #107 · 20.5K reputationPosted Feb 22, 2010, 7:40 AM EST
j l68 reputationPosted Feb 22, 2010, 8:18 AM EST
Here is the code that I've tried. I get an exception error at the "IF" statement
int rowIndex = 1; int colIndex = 1;
excelApp.Cells[rowIndex, colIndex] = "True";
if (excelApp.Range[rowIndex, colIndex].Value = "True")
excelApp.Range[rowIndex, colIndex].Interior.ColorIndex = 4;
else
excelApp.Range[rowIndex, colIndex].Interior.ColorIndex = 3;
Can anyone tell me whats wrong with my code?
J