You can't, in my opinion. When you pass an array into Sumif when it is expecting a range, it returns a type mismatch. You can try using this Sumif substitute that I made.
Testing requires the range A1:B6 to look like this.
| A |
B |
| a |
1 |
| a |
1 |
| b |
1 |
| c |
1 |
| d |
1 |
| a |
1 |
Code:
Sub test()
Dim arr() As Variant
arr = Range("A1:B6")
Debug.Print mySumif(arr, "a", 1, 2)
End Sub
Function mySumif(ByVal arr As Variant, ByVal criteria As Variant, ByVal criteriaColNo As Integer, ByVal sumColNo As Integer) As Double
For i = LBound(arr) To UBound(arr)
If arr(i, criteriaColNo) = criteria Then mySumif = mySumif + arr(i, sumColNo)
Next i
End Function
Output:
3