title: Application.WorksheetFunction.SumProduct wsf.CountIfs with 4 arrays
body: <p>I'm trying to get an Application.WorksheetFunction.SumProduct wsf.CountIfs to work with 4 arrays. So far I always get incorrect results for a1 and b1 :(</p>
  
  <p>This is my code: </p>
  
  <pre><code>Dim lastrow As Long
  Dim wsf
  lastrow = Sheet2.Cells(Sheet2.Rows.Count, "M").End(xlUp).Row
  Set wsf = Application.WorksheetFunction
  
  Doctors = Array("Peter","Sam","Henry")
  Emergency = Array("Y","N")
  Specialty = Array("GP","Specialist")
  Rank = Array("Senior","Junior")
  
  a1 = Application.WorksheetFunction.SumProduct(wsf.CountIfs(Sheet2.Range("P2:P" &amp; lastrow), Doctors, Sheet2.Range("M2:M" &amp; lastrow), Emergency, Sheet2.Range("O2:O" &amp; lastrow), Specialty, Sheet2.Range("R2:R" &amp; lastrow), Rank))
  
  b1 = Application.WorksheetFunction.SumProduct(wsf.SumIfs(Sheet2.Range("G2:G" &amp; lastrow), Sheet2.Range("P2:P" &amp; lastrow), Doctors, Sheet2.Range("M2:M" &amp; lastrow), Emergency, Sheet2.Range("O2:O" &amp; lastrow), Specialty, Sheet2.Range("R2:R" &amp; lastrow), Rank))
  </code></pre>
  
  <p>The best I've got to is using only 2 criteria through <strong>wsf.transpose</strong>:</p>
  
  <pre><code>a1 = Application.WorksheetFunction.SumProduct(wsf.CountIfs(Sheet2.Range("P2:P" &amp; lastrow), Doctors, Sheet2.Range("M2:M" &amp; lastrow), wsf.Transpose(Emergency))) 
  </code></pre>
  
  <p>The same does not work on more than 2 criteria.</p>
  
  <p>Any clues?</p>