title: How to use SumByColor across multiple sheets?
body: <p>I use the formula <code>SumByColor</code> and want to add the values of cells with the same color across multiple sheets.</p>
  
  <pre><code>=SumByColor(A2;'Project 1:Project 3'!B3:B28)
  </code></pre>
  
  <p>I tried the above formula, but get <code>#VALUE</code> returned.</p>
  
  <p>If I do <code>=SumByColor(A2;'Project 1'!B3:B28)+SumByColor(A2;'Project 2'!B3:B28)</code> etc it works but I have > 15 sheets so it becomes a very long formula.</p>
  
  <p>I used this VBA: </p>
  
  <pre><code>Function SumByColor(CellColor As Range, SumRange As Range)
  Application.Volatile
  Dim ICol As Integer
  Dim TCell As Range
  ICol = CellColor.Interior.ColorIndex
  For Each TCell In SumRange
  If ICol = TCell.Interior.ColorIndex Then
  SumByColor = SumByColor + TCell.Value
  End If
  Next TCell
  End Function
  </code></pre>