View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.misc
Ron Rosenfeld Ron Rosenfeld is offline
external usenet poster
 
Posts: 5,651
Default ACRONYM OF CAPS ONLY

On Mon, 23 Feb 2009 00:08:03 -0800, FARAZ QURESHI
wrote:

I want 2 develop a UDF like Acro, which would return the acronymn of only the
letter in Caps. For example
=ACRO(A1)
when A1 is:
"United States of America"
would return:
USA
and NOT:
USOA



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 =ACRO(A1) in some
cell.



================================
Option Explicit
Option Compare Binary
Function ACRO(str As String) As String
Dim i As Long
Dim sTemp As String

For i = 1 To Len(str)
sTemp = Mid(str, i, 1)
If sTemp Like "[A-Z]" Then
ACRO = ACRO & sTemp
End If
Next i

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