enter code herei try to sum all positive value in my array but every time object not found or parameter misssing error seen.
Option Explicit Sub trail2() With ThisWorkbook Dim arr1 As New ArrayList arr1.Add 20 arr1.Add -15 arr1.Add 20.77 msgbox Application.WorksheetFunction.CountIf(arr1, ">0") end with end sub error = object not found or parameter misssing error seen
i also try on range but thats also not working
Option Explicit Sub trail2() dim rr as variant dim i as variant With ThisWorkbook rr = Range(.Sheets("data").Cells(2, 5), .Sheets("data").Cells(4, 5)) msgbox Application.WorksheetFunction.CountIf(rr, ">0") end with end sub same data as per array but error seen. error = object required i don't want that sheet data so i need only array for sumif. how to slove it ?
CountIfmust be aRange, so that approach won't work. Use a loop.msgbox = ....---->MsgBox .... No=.rris aVariantarray, not aRange.