title: Excel User Defined Function: change the cell's color
body: <p>I have a user defined function in Excel. It is called as a formula function from spreadsheet cells and works fine.</p>
  
  <p>I'd like the function to be able to change the cell's color depending on the value that it returns. Essentially, changing the cell's color is a side effect of the function.</p>
  
  <p>I tried</p>
  
  <pre><code>Application.ThisCell.Interior.ColorIndex = 2
  </code></pre>
  
  <p>But it fails.</p>