Hello All,

I am having an error with " Expect array " Point at the red Row.

This function is called in my Main SuB I don't think the error is related. What would be the cause as I can not see the error.

Your help is much appreciated.

Thank you.

Najwa.

Function Duplicate(X As Range, a As Integer) As Integer()

Dim i As Long
Dim t As Long

i = Application.CountA(Range("X"))
ReDim a(1 To i, 1 To 1)

    For t = 1 To i
    
    If Range("X").Cells(t, 1).Value = "" Then
    a(t, 1) = 0
        Else
    a(t, 1) = Application.CountIf(Range("X").Columns(a), Range("X").Cells(t, a).Value) - 1
    End If
    Next
    Duplicate = a
End Function