title: VBA code - Sumbycellscolor
body: <pre><code>LastRow = Cells(Rows.Count, 12).End(xlUp).Row
  Cells(LastRow + 1, 12).Formula = "=sumcellsbycolor(K1:K" &amp; LastRow &amp; ",(colorindex=6))"
  </code></pre>
  
  <p>In actual formula instead of (colorindex=6) we should select the cell of which color we need. But since I do not have fixed cell to give ref. </p>
  
  <p>So how can I use this color index in the above formula</p>