Extract Capital Letters

  • Thread starter Thread starter jnf40
  • Start date Start date
J

jnf40

Using VBA how would I have the username like Joseph T. Smith be JTS in a
cell? The name could be any length, and if there is not a middle initial such
as Pete Loveless it would be PL.
Thanks for any and all advice and examples.
 
Recollect one way is to use this fine UDF (FrstLtrs) by Ron Rosenfeld

Here's the extract from Ron's reply to get you going ..

" .. >Hi, I want to extract the 1st letter of each word in a string.
So for eg, in the string "my name is fred" I want to extract "mnif"
....

It's easy with a User Defined Function.
<alt><F11> opens the VB Editor.

Ensure your project is highlighted in the project explorer window, then
Insert/Module and paste the code below into the window.

To use this UDF, enter a formula of the type
=FrstLtrs(A1) where your string is in A1.

'===========
Function FrstLtrs(str As String) As String
Dim temp
Dim i As Long

temp = Split(Trim(str))

For i = 0 To UBound(temp)
FrstLtrs = FrstLtrs & Left(temp(i), 1)
Next i

End Function
'============
--ron

...."


---
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top