title: Autofill Application.Countifs.Formula VBA Excel
body: <p>I think this might be a simple question but I can't seem to find a way to autofill an Application.WorksheetFunction.SumProduct(wsf.CountIf formula so that the row number would change as the formula goes down.</p>
  
  <p>I want to autofill this formula for B2 till LastRow from Column A
  <code>Application.WorksheetFunction.SumProduct(wsf.CountIfs(Sheet2.Range(**B2 Here**), Doctors, Sheet2.Range(**B2 Here**), wsf.Transpose(Emergency)))</code></p>
  
  <p>So lets assume that the last used row for column A is 6, so the formula should autofill from B2 until B6 such as:</p>
  
  <p>B3 = <code>Application.WorksheetFunction.SumProduct(wsf.CountIfs(Sheet2.Range(**B3 Here**)....</code></p>
  
  <p>B4 = <code>Application.WorksheetFunction.SumProduct(wsf.CountIfs(Sheet2.Range(**B4 Here**)....</code></p>
  
  <p>B5 = <code>Application.WorksheetFunction.SumProduct(wsf.CountIfs(Sheet2.Range(**B5 Here**)....</code></p>
  
  <p>B6 = <code>Application.WorksheetFunction.SumProduct(wsf.CountIfs(Sheet2.Range(**B6 Here**)....</code></p>
  
  <p>I don't want to use .Formula "=SUMPRODUCT(COUNTIFS....." approach so that I can use arrays as the criteria vary according to the selected dropdown choices.</p>
  
  <p>Any clues?</p>