Function GetSentences(ByVal Sentences As String) As Collection
'Delete space
Sentences = Trim(Sentences)
Dim sList As New Collection
Dim RE As Object, REMatches As Object
Set RE = CreateObject("vbscript.regexp")
With RE
.MultiLine = False
.Global = True
.IgnoreCase = False
.Pattern = "(\S.+?[.?])(?=\s+|$)\s"
End With
'Split sentences by the period or question mark
Set REMatches = RE.Execute(Sentences)
Dim m As Variant
For Each m In REMatches
'Delete space
m = Trim(m)
'Add each line
sList.Add (m)
'Remove add lines
Sentences = Replace(Sentences, m, "")
Next
'Left text
If Sentences <> "" Then sList.Add (Trim(Sentences))
Set GetSentences = sList