Extract Nth Word from a String
Here's how to Extract the Nth Word from a String
Function GetNthWord(strStringFrom As String, strSplitCharacter As String, intExtractWordNumber As Integer) As String On Error Resume Next GetNthWord = VBA.split(strStringFrom, strSplitCharacter)(intExtractWordNumber - 1) If Err.Number <> 0 Then GetNthWord = "" End If On Error GoTo 0 End Function Sub ExecuteNthWord() MsgBox GetNthWord("Hi:Hello:Nick", ":", 2) End Sub
Extract Nth Word from String
Hi,
Nice, works like a treat.
Is it an answer or do you have a question? ;-)
Grtnx,
JPH