title: Excel: Get cell color
body: <p>1) How do I get the color of a cell using an Excel Macro? I couldn't get this function work:</p>
  
  <pre><code>Sub BGCol(MRow As Integer, MCol As Integer)  
  bgColor = Cells(MRow, MCol).Interior.ColorIndex  
  End Sub
  </code></pre>
  
  <p>2) In the cell x,y I want to have the following formula:</p>
  
  <p><code>=BGCol(x,4)</code></p>
  
  <p>So how do I get the current row index?</p>