title: Sumifs in Excel-VBA
body: <p>I have some problem with <code>sumifs</code> in vba:</p>
  
  <pre><code>Dim Arg1 As Range 'the range i want to sum
  Dim Arg2 As Range 'criteria range
  Dim Arg3 As Variant 'the criteria
  
  Set Arg1 = ThisWB.Sheets("Sheet1").Range("B2:B100")
  Set Arg2 = ThisWB.Sheets("Sheet1").Range("C1:C100")
  Set Arg3 = ThisWB.Sheets("Sheet2").Range("A2:A12")
  
  For i = 2 To 12
  Workbooks("x.xlsx").Worksheets("Sheet2").Cells(i, LastColumn) _
  = Application.WorksheetFunction.SumIfs(Arg1, Arg2, Arg3)
  
  
  Next
  </code></pre>
  
  <p>I always get a "Type mismatch" error</p>
  
  <p>Could anybody help me to fix the code?</p>
  
  <p>Thank you in advance.</p>