I have a single cell formatted as text into which a variety of information
might be entered. What I want to do is extract the first letter of each word
into another cell.
Examples:
A1 A2
Basalt Regional Library BRL
Carbondale Rural Fire Protection District CRFPD
Williams Residence WR
Here is a UDF that will return the first letter of each word.
To enter this User Defined Function (UDF), <alt-F11> opens the Visual Basic
Editor.
Ensure your project is highlighted in the Project Explorer window.
Then, from the top menu, select Insert/Module and
paste the code below into the window that opens.
To use this User Defined Function (UDF), enter a formula like
=FirstLtrs(A1)
in some cell.
======================
Option Explicit
Function FirstLtrs(S As String) As String
Dim re As Object, mc As Object, m As Object
Set re = CreateObject("vbscript.regexp")
re.Global = True
re.Pattern = "\b\w"
If re.test(S) = True Then
Set mc = re.Execute(S)
For Each m In mc
FirstLtrs = FirstLtrs & m
Next m
End If
End Function
========================
--ron