Hi
My VBA is a little rusty, but here goes. I'm trying to write a function that takes two arrays and counts the number of cells with numbers in them according to certain rules. The problem is that whatever I do, a #VALUE error appears in the worksheet cell when I try to run it. My code is below, and the array inputs are meant to be ranges in the worksheet.
Thanks in advance.
Public Function countOwn(id As Variant, ByRef Xarr() As Variant, ByRef Yarr As Variant) As Long
If UBound(Xarr, 1) <> UBound(Yarr, 1) Or UBound(Xarr, 2) > 1 Or UBound(Yarr, 2) > 1 Then
MsgBox "The input arrays must be the same length and of dimension 1"
Exit Function
End If
Dim i As Integer
countOwn = 0
For i = 1 To UBound(Xarr, 1)
If Xarr(i) = id And IsNumeric(Yarr(i)) Then countOwn = countOwn + 1
Next i
End Function
Bookmarks