Hi,
I was trying to extract capital words from a string, and was given a great code seen below. My original goal was to extract capital letter like seen in Example 1 below. Now I am wondering if anyone can help me with EXCLUDING the following:
- The first word in the string
- Any words which begin a new sentence if the cell includes multiple sentences.
- A specific word, like Fox
Example 1 (Original):
A1: The quick brown Fox Jumps over the lazy dog.
Ideally in B1: The Fox Jumps
Example 2 (New) Excluding words beginning a sentence and the word Fox:
A1: The quick brown Fox Jumps over the lazy dog. It was Very Neat.
Ideally in A1: Jumps Very Neat
Public Function ExtractProperCase(ByVal sText As String)
Dim iChar As Integer
Dim iStart As Integer
Dim sReturn As String
For iChar = 1 To Len(sText)
iStart = iChar
If Asc(Mid$(sText, iChar, 1)) > 64 And _
Asc(Mid$(sText, iChar, 1)) < 91 Then
Do While Mid$(sText, iChar, 1) <> " " And _
iChar < Len(sText) + 1
iChar = iChar + 1
Loop
sReturn = sReturn & _
Mid$(sText, iStart, iChar - iStart) & " "
End If
Next
ExtractProperCase = Trim$(sReturn)
End Function
Thanks in advance!
-Andrew
Bookmarks