Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Public Function CountCSVWords(strString As String, strDelimiter As String) As Integer
'
' Counts words in a string separated by commas.
' Adapted from MS Neat Code 97 database by J Barnett.
Dim WC As Integer, Pos As Integer
WC = 1
Pos = InStr(strString, strDelimiter)
Do While Pos > 0
WC = WC + 1
Pos = InStr(Pos + 1, strString, strDelimiter)
Loop
CountCSVWords = WC
End Function
Public Function GetCSVWord(strString As String, Indx As Integer, strDelimiter As String)
'
' Returns the <Indx>th word from a <delimiter>-separated string.
' For example, GetCSVWord("Nancy, Bob", 2, ",") returns Bob.
' Adapted from MS Neat Code 97 database by J Barnett.
'
Dim WC As Integer, Count As Integer, SPos As Integer, EPos As Integer
WC = CountCSVWords(strString, strDelimiter)
If Indx < 1 Or Indx > WC Then
GetCSVWord = Null
Exit Function
End If
Count = 1
SPos = 1
For Count = 2 To Indx
SPos = InStr(SPos, strString, strDelimiter) + 1
Next Count
EPos = InStr(SPos, strString, strDelimiter) - 1
If EPos <= 0 Then EPos = Len(strString)
GetCSVWord = Mid(strString, SPos, EPos - SPos + 1)
End Function