title: converting sumif forimula from excel to macro vba - Prolem 2 : converting cell range
body: <p>When I'm running code below </p>
  
  <pre><code>Sub test2() Dim i, 
  Rownumber As Integer 
  Rownumber = Sheets("Sheet4").Range("A65536").End(xlUp).Row
  
      For i = 2 To Rownumber
  
              Sheets("Sheet4").Cells(i, 3).Formula = "=sumif(Sheet3!$A$2:$A$10, Sheet4!A2, Sheet3!$B$2:$B$10)"
  
          Next i
           End Sub
  </code></pre>
  
  <p>The macro is running well, but when I convert it into macro VBA:</p>
  
  <pre><code>Sub test2()
  Dim i, Rownumber As Integer
  Rownumber = Sheets("Sheet4").Range("A65536").End(xlUp).Row
  
  For i = 2 To Rownumber
  
          Sheets("Sheet4").Cells(i, 3).Value = Application.WorksheetFunction.SumIfs(Sheets("Sheet3").Range("A2:A10"), Sheets("Sheet4").Cells(2, 1), Sheets("Sheet3").Range("B2:B10"))
  
      Next i
  
  End Sub
  </code></pre>
  
  <p>It gives me error --> <strong>run type error 13, type missmatch</strong></p>
  
  <p>Any clues why this happens and how to fix it? -- <strong><em>cased closed</em></strong></p>
  
  <p>Thanks</p>
  
  <p><em><strong>PROBLEM NO 2</em></strong></p>
  
  <p>code below is running well when it's executes :</p>
  
  <pre><code> For j = 3 To Colnumber
  
              For i = 2 To Rownumber
              Sheets("Sheet2").Cells(i, j).Value = Application.WorksheetFunction.SumIfs(Sheets("3G").**Range("F2:F6991")**, Sheets("3G").Range("E2:E6991"), Sheets("Sheet2").Cells(i, 1))
  
  
              Next i
  
          Next j
  </code></pre>
  
  <p>but why when i change it onto :</p>
  
  <pre><code>Sheets("Sheet2").Cells(i, j).Value = Application.WorksheetFunction.SumIfs(Sheets("3G").**Range(Cells(2, 6), Cells(6991, 6))**, Sheets("3G").Range("E2:E6991"), Sheets("Sheet2").Cells(i, 1))
  </code></pre>
  
  <p>it gave me error : error 1004, application defined or defined-object error ??</p>
  
  <p>TIA</p>