title: Unable to get Averageifs property of WorksheetFunction class
body: <p>I created a macro which summarizes a series of Excel forms into outputs, organized by sheets, rows and columns. The program creates a sheet, populates a table, and repeats.</p>
  
  <p>The only thing I have left to do is to populate the cells with a formula. It's a very simple AverageIfs formula and I am getting the "Unable to get Averageifs property of WorksheetFunction class" error. I tried a bunch of things that I read, but to no avail.</p>
  
  <p>So far I</p>
  
  <ul>
  <li>Copied and pasted the formula itself into a separate macro (it ran, so it isn't a typo)</li>
  <li>Removed the formula and checked to make sure every variable in the formula is the value I expect it to be at this point in the program (each one is)</li>
  </ul>
  
  <p>Here is the relevant excerpt of my code. I am omitting a large portion, but I can assure all variables are defined and the loop works properly if I replace the AverageIfs function with a hard value (e.g. "1").</p>
  
  <pre><code>'Start Loop
  VBid = 0
  ZEval = 0
  
  Do While VBid &lt;&gt; NumBidder
      ActiveBid = ListInputSheet.Range("H" &amp; 7 + VBid).Value
      Set AnalysisSheet = AnalysisBook.Sheets.Add
      AnalysisSheet.Name = ActiveBid
  
      XRow = 4
      AnalysisSheet.Range("C" &amp; XRow).Value = ActiveBid
      ZEval = 0
  
      'Loop all evaluators down rows
      Do While ZEval &lt;&gt; NumEval
          ActiveEval = ListInputSheet.Range("E" &amp; 7 + ZEval).Value
          AnalysisSheet.Range("D" &amp; XRow).Value = ActiveEval
          AnalysisSheet.Range("D" &amp; XRow).Select
          WSub = 0
  
          'Loop all Category Averages across row in columns
          Do While WSub &lt;&gt; NumCategories
              ActiveCell.Offset(0, 1).Select
  
              Form = Application.WorksheetFunction.AverageIfs(SummarySheet.Range("F1:F10000"), SummarySheet.Range("A1:A10000"), ActiveEval, SummarySheet.Range("B1:B10000"), ActiveBid, SummarySheet.Range("D1:D10000"), WSub + 1)
              ActiveCell.Value = Form
  
              WSub = WSub + 1
          Loop
  
          XRow = XRow + 1
          ZEval = ZEval + 1
  
      Loop
      'End evaluator loop
      VBid = VBid + 1
  Loop
  'End Bidder loop
  </code></pre>