Countif Vba Arrays

  • Hello. I am trying to use the countif function in vba on memory only arrays. For example:



    should give b = 5 and c = 2. Currently b = 5 but c = an array with 5 x 2015 errors.


    Any ideas?

  • Re: Countif Vba Arrays


    try


    Code
    Sub mem_countif()
      Dim a(), i&, iCnt&
      a = Array(1, 2, 3, 4, 5)
      iCnt = 0
      For i = 0 To UBound(a, 1)
        iCnt = iCnt - (a(i) > 3)
      Next i
      MsgBox iCnt
    End Sub


    filippo

  • Re: Countif Vba Arrays


    Thank you, though can already do loops. Was trying to keep to worksheet functions, as I believe that they are quicker that UDFs.


    Cheers anyway.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!