Extract Uppercase Letters

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

jnf40

Accidentally posted to Excel General Questions earlier.
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.
 
You could pass your user name into this function and it will return the
upper case letters that you want...

Function GetUpperCaseLetters(Text As String) As String
Dim X As Long
For X = 1 To Len(Text)
If Mid$(Text, X, 1) Like "[A-Z]" Then
GetUpperCaseLetters = GetUpperCaseLetters & Mid$(Text, X, 1)
End If
Next
End Function

Rick
 
Thanks works great

Rick Rothstein (MVP - VB) said:
You could pass your user name into this function and it will return the
upper case letters that you want...

Function GetUpperCaseLetters(Text As String) As String
Dim X As Long
For X = 1 To Len(Text)
If Mid$(Text, X, 1) Like "[A-Z]" Then
GetUpperCaseLetters = GetUpperCaseLetters & Mid$(Text, X, 1)
End If
Next
End Function

Rick


jnf40 said:
Accidentally posted to Excel General Questions earlier.
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.
 
Rick did you ever get a chance to look at the rest of that code from the
"Check Characters and Change as Needed" post from 4/8/08?

Rick Rothstein (MVP - VB) said:
You could pass your user name into this function and it will return the
upper case letters that you want...

Function GetUpperCaseLetters(Text As String) As String
Dim X As Long
For X = 1 To Len(Text)
If Mid$(Text, X, 1) Like "[A-Z]" Then
GetUpperCaseLetters = GetUpperCaseLetters & Mid$(Text, X, 1)
End If
Next
End Function

Rick


jnf40 said:
Accidentally posted to Excel General Questions earlier.
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.
 
Hmmm, I tried it and it "BOMD" on "Bob O. McDuff"

Rick Rothstein (MVP - VB) said:
You could pass your user name into this function and it will return the
upper case letters that you want...

Function GetUpperCaseLetters(Text As String) As String
Dim X As Long
For X = 1 To Len(Text)
If Mid$(Text, X, 1) Like "[A-Z]" Then
GetUpperCaseLetters = GetUpperCaseLetters & Mid$(Text, X, 1)
End If
Next
End Function

Rick


jnf40 said:
Accidentally posted to Excel General Questions earlier.
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.
 
While I'm sure there are lot's of other exception (and I'm not completely
sure BOMD is not what the OP wants), you can handle the McDuff problem this
way...

Function GetUpperCaseLetters(Text As String) As String
Dim X As Long
For X = 1 To Len(Text)
If Mid$(StrConv(Text, vbProperCase), X, 1) Like "[A-Z]" Then
GetUpperCaseLetters = GetUpperCaseLetters & Mid$(Text, X, 1)
End If
Next
End Function

Rick


Charlie said:
Hmmm, I tried it and it "BOMD" on "Bob O. McDuff"

Rick Rothstein (MVP - VB) said:
You could pass your user name into this function and it will return the
upper case letters that you want...

Function GetUpperCaseLetters(Text As String) As String
Dim X As Long
For X = 1 To Len(Text)
If Mid$(Text, X, 1) Like "[A-Z]" Then
GetUpperCaseLetters = GetUpperCaseLetters & Mid$(Text, X, 1)
End If
Next
End Function

Rick


jnf40 said:
Accidentally posted to Excel General Questions earlier.
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.
 
Looks fine to me, what's wrong if that's what you are suggesting

Regards,
Peter T


Charlie said:
Hmmm, I tried it and it "BOMD" on "Bob O. McDuff"

Rick Rothstein (MVP - VB) said:
You could pass your user name into this function and it will return the
upper case letters that you want...

Function GetUpperCaseLetters(Text As String) As String
Dim X As Long
For X = 1 To Len(Text)
If Mid$(Text, X, 1) Like "[A-Z]" Then
GetUpperCaseLetters = GetUpperCaseLetters & Mid$(Text, X, 1)
End If
Next
End Function

Rick


jnf40 said:
Accidentally posted to Excel General Questions earlier.
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.
 

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