Hello,
I have found a few answers on here that get me 75% of the way to what I need, but was hoping somebody could help me get it to 100%. I am looking for VBA script that will scan a single cell text string and return all words or phrases containing capital letters.
The rules I need are:
- IF the capitalized word is directly adjacent to another capitalized word(s), group them as a phrase.
- IF the capitalized word is on its own (i.e. not directly neighboring another capital word) then it is parsed on its own
- IF the word comes after a period (.), ignore.
I would also like each word or phrase to be placed in its own cell. So, for example, the result should look like this:
This is the VBA I found that gets me partially there:
Many thanks!
I have found a few answers on here that get me 75% of the way to what I need, but was hoping somebody could help me get it to 100%. I am looking for VBA script that will scan a single cell text string and return all words or phrases containing capital letters.
The rules I need are:
- IF the capitalized word is directly adjacent to another capitalized word(s), group them as a phrase.
- IF the capitalized word is on its own (i.e. not directly neighboring another capital word) then it is parsed on its own
- IF the word comes after a period (.), ignore.
I would also like each word or phrase to be placed in its own cell. So, for example, the result should look like this:
John Smith is joining ACME Solutions as its new CTO. He will replace Susan Johnson who is departing for ACME2 | John Smith | ACME Solutions | CTO | Susan Johnson | ACME2 |
This is the VBA I found that gets me partially there:
VBA Code:
Option Explicit
Function StrExtract(Str As String, Optional IgnoreFirst As Boolean = False) As String
Dim tmp As Variant, tmp2 As String, x As Long, y As Long
If IgnoreFirst Then x = 1
tmp = Split(Str, " ")
For y = x To UBound(tmp)
If tmp(y) = StrConv(tmp(y), vbProperCase) Then tmp2 = tmp2 & tmp(y) & ", "
Next
If IgnoreFirst And tmp2 = vbNullString Then
StrExtract = tmp(0)
Else
StrExtract = Replace(Left(tmp2, Len(tmp2) - 2), "?", "")
End If
End Function
Many thanks!