title: Sumif criteria with for loop in VBA
body: <pre><code>Dim i As Integer, j As Integer, k As Integer, l As Integer
  
  i = ActiveSheet.PivotTables(1).TableRange2.Rows.Count + 1
  j = ActiveSheet.PivotTables(1).TableRange2.Columns.Count 
  k = ActiveSheet.PivotTables(1).TableRange2.Rows.Count - 7 
  
  For l = 2 To j
      Cells(i + 2, l).Value = WorksheetFunction.SumIf(Range(Cells(9, l), Cells(i, l)), "&gt;0", Range(Cells(9, l), Cells(i, l)))
  Next l
  </code></pre>
  
  <p>Hi, I am trying to use sumif function in vba. The point is to do this in loop, which depends on the number of columns. I do not actually now what is wrong here, but I think that probably there is something with criteria I took. I want to sum all cells with number higher than 0 and not sure how to write this.</p>