I have a User Defined Function (for finding the next minimum value in a range) that is not working for nonconcurrent ranges when called from within a worksheet. It returns #VALUE!

This works: =nextmin(A11:A17)
This does not work: =nextmin(D13,E13,F13,F16)

However calling the function from within vba works:
Private Sub testIng()
    Dim sampleInt As Integer
    
    sampleInt = NEXTMIN(Range("D13,E13,F13,F16"))
    MsgBox sampleInt
End Sub
Here is the function:
Public Function NEXTMIN(ByVal minRange As Range)
    Dim oCell As Range
    Dim compareVal As Integer
    Dim i As Integer
    Dim a() As Integer
    Dim fistSwitch As Integer
    
    For Each oCell In minRange
        compareVal = Application.Min(minRange)
        If oCell.Value <> compareVal Then
            ReDim Preserve a(i)
            a(i) = oCell.Value
            i = i + 1
        End If
    Next
    
    a = SortArray(a)
    NEXTMIN = a(LBound(a))
End Function
If interested, here is the subsequent array sorting function I found (with link to author page):
Public Function SortArray(ByRef TheArray As Variant)
'http://www.freevbcode.com/ShowCode.asp?ID=3197
    Dim Sorted As Boolean
    Dim x As Integer
    Dim Temp As Integer
    Sorted = False
    Do While Not Sorted
        Sorted = True
    For x = 0 To UBound(TheArray) - 1
        If TheArray(x) > TheArray(x + 1) Then
            Temp = TheArray(x + 1)
            TheArray(x + 1) = TheArray(x)
            TheArray(x) = Temp
            Sorted = False
        End If
    Next x
    Loop
    SortArray = TheArray
End Function
Any help is appreciated. Thanks so much.