Function Initials(Txt As String) As String
Dim Arr As Variant
Dim x As Integer
Arr = Split(Txt, " ")
For x = LBound(Arr) To UBound(Arr)
Initials = Initials & Left(Arr(x), 1)
Next x
End Function
Book1 | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
A | B | C | D | E | F | G | H | |||
1 | ThisistheFirstSentence | TitFS | ||||||||
2 | ThisistheSecondSentence | TitSS | ||||||||
3 | Myfavoriteanimalisacat! | Mfaiac | ||||||||
4 | Myreal.Excitingx-raycaneatlava! | Mr.Excel | ||||||||
5 | ||||||||||
6 | ||||||||||
7 | ||||||||||
8 | ||||||||||
9 | ||||||||||
10 | ||||||||||
11 | ||||||||||
12 | ||||||||||
13 | ||||||||||
14 | ||||||||||
15 | ||||||||||
16 | ||||||||||
Sheet1 |
Function Initials(Target As String) As String
Dim x As Integer
Target = Application.WorksheetFunction.Trim(Target)
If Mid(Target, 1, 1)<> " " Then Initials = Mid(Target, 1, 1)
For x = 1 To Len(Target)
If Mid(Target, x, 1) = " " Then Initials = Initials & Mid(Target, x + 1, 1)
Next
End Function