Actually, after noticing the "ByRef/ByVal" thing I didn't even got through your code. This prevented me from further noticing your previous function didn't act on the passed arrays (Xs and Ys) but on local ones (ArrX and ArrY) only.
you could be interested in the following code alternatives to have it shorter and cleaner (as less variables as possible), which is always a good thing for maintenace purposes.
I put some comments to explain.
Code:
Option Explicit
Public Sub ShortDist()
Dim ArrX() As Double, ArrY() As Double '<--- dimensioning ArrX and ArrY as arrays, you can hereinafter use arrays operations
Dim pnt2(2) As Double
Dim x As Long, cnt As Long
BlockSpecs wholedrawing, , ArrX, ArrY '<--- remember you must change ArrX and ArrY "Dim" declarationin "BloclSpecs" too, to match the ones in this sub
For x = 0 To UBound(ArrX)
If Not pnt2(0) = 0 Then SortArray ArrX, ArrY, pnt2(0) '<--- just pass the pnt2 coordinate you need only
For c = 1 To UBound(ArrX)
...
End Sub
Function SortArray(ByRef ArrX() As Double, ByRef ArrY() As Double, ByVal pnt2 As Double) '<--- changed this Function "signature" to match the main Sub settings
Dim i As Long, x As Long, j As Long, cnt As Long ' <--- you must declare each variable individually, otherwise those who are not will be taken as of "variant" type
cnt = UBound(ArrX) - 1
ReDim Xs(cnt) As Double
ReDim Ys(cnt) As Double
For i = 0 To UBound(ArrX)
If Not ArrX(i) = 0 Then
x = i + 1
Select Case True
Case ArrX(i) = pnt2
j = 0
Case Not x > cnt
j = x
Case Else
j = x - 2
End Select
Xs(j) = ArrX(i)
Ys(j) = ArrY(i)
End If
Next i
ReDim ArrX(cnt)
ReDim ArrY(cnt)
ArrX = Xs
ArrY = Ys
End Function
besides I'd recall my previous warning concerning the use of UBound(ArrX) as a loop termination condition while changing the ArrX array dimension in the loop itself.
finally I'd also think over carefully managing the numeric matching between two coordinates or between one coordinate and a number (zero). since you could have a "zero" coordinate that has actually some far decimals after the separator. you may then consider the use of checking the matching for less then a tolerance like for instance
Code:
Case (ArrX(i) >= pnt2-0.000001) and (ArrX(i) <= pnt2+0.000001)
and the likes