Noob question: I want to count non-empty elements of an array?
My attempt:
Dim Arr(1 To 15) As Double
'populating some of the elements of Arr
'...
Dim nonEmptyElements As Integer, i As Integer
nonEmptyElements = 0: i = 0
For i = LBound(Arr) To UBound(Arr)
If Not Arr(i) = "" Then
nonEmptyElements = nonEmptyElements + 1
End If
Next
With this program, I get the error message: Type mismatch on if.
If we try to change the if condition to If Not IsEmpty(Arr(i)) Then, and as a result we get nonEmptyElements = 15.
Any suggestions on how to fill in the code?
source
share