0

I need to set the Fill Color (Background) of the Excel Cell to Red or Green based on some threshold value. I have used Style.Fill.BackgroundColor and Style.Font.FontColor property conditionally to fill the background color and font color but then found out that the NumberFormat can also be used to set the font color conditionally like this:

Style.NumberFormat.Format = "[Red][<=100];[Blue][>100]";

Is there any way I can set the fill color by using the NumberFormat property of the cells so that I can leave checking the condition on MS Excel itself?

Nikhil Girraj
  • 1,135
  • 1
  • 15
  • 33

1 Answers1

0

Is there any way I can set the fill color by using the NumberFormat property of the cells so that I can leave checking the condition on MS Excel itself?

No. There isn't. Conditional formatting applied via .NumberFormat property only affects text/numbers inside a cell and not the background colour.

What you are doing is explained here.

Excel has a feature called Conditional Formatting which can colour both text and background depending on a condition you set. Here's the link (Thanks to Manuel)