In response to a recent comment, I have modified the CSpline2 spreadsheet so that the CSplineA and CHSplineA functions will accept x values list in descending order, as well as ascending. For more details of the background to the functions, and how to use them see: Daily Download 22: Splines and Curves. The new version can be downloaded from:

__CSpline2.zip__

The code for the checking and reversing the x data is quite short:

Function CheckAscX(Xa As Variant, Ya As Variant, n as Long) As Boolean Dim Temp As Variant, i As Long ' If last x < first x, reverse Xa and Ya and return True, else return False If Xa(n, 1) < Xa(1, 1) Then Temp = Xa For i = 1 To n Xa(i, 1) = Temp(n - i + 1, 1) Next i Temp = Ya For i = 1 To n Ya(i, 1) = Temp(n - i + 1, 1) Next i CheckAscX = True Exit Function End If CheckAscX = False End Function

Then the CheckAscX function just needs to be called from the spline function:

... Xa = GetArray(Xa) Ya = GetArray(Ya) n = UBound(Xa) RevX = CheckAscX(Xa, Ya, n) ...

The spline functions will now work with the X values sorted in either direction: