I have this function which returns as string the value in comma separated string which is in order of given integer value.
Private Sub TestGetNthNumber()
    Debug.Print GetNthNumber("NUMBERS 5088, 5089, 5090, 5091", 2)
End Sub
Public Function GetNthNumber(sMark As String, iOrder As Integer) As String
    Dim sTemp As String
    Dim sNumber As String
    Dim iLoop As Integer
    If sMark = "" Then
        Exit Function
    End If
    sTemp = sMark & ","
    For iLoop = 1 To iOrder
        sTemp = Mid(sTemp, InStr(sTemp, " "))
        sNumber = Trim(Left(sTemp, InStr(sTemp, ",") - 1))
        sTemp = Mid(sTemp, InStr(sTemp, ",") + 1)
    Next
    GetNthNumber = sNumber
End Function
The test Sub will return "5089" as its given number 2 in the list of values.
My question; Is there better method to do this instead of the messy string manipulation with Mid, Left and InStr? Like a way to turn the comma separated string values into an array?
Another problem;
It is possible the string is in format "NUMBERS 5088, 5089, 5090 and 5091". But for this I assume simply replacing " and" with "," before handling it does the trick.
 
     
    