Leading the way in Microsoft Office Development
 Home|Excel|Word|PowerPoint|Consultancy|Feedback|Contact 
 Microsoft Excel > Functions User Defined > ACRONYM< Previous | Next > 

 

ACRONYM(sText As String) As String

 
 

Returns the first letter of each word.

 

 
sTextThe text you want the acronym for.
 

 

REMARKS

 
 
  • ??

     

     
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    Option Explicit

    Public Function ACRONYM(ByVal sText As String, _
                   Optional ByVal bJustCapitals As Boolean = False) As String

    Dim inextspace As Integer
    Dim sfirstcharacter As String
    Dim sword As String

        sText = VBA.Trim(sText)
        Do While VBA.Len(sText) > 0
           inextspace = VBA.InStr(1, sText, " ")
           If inextspace > 0 Then
              sword = VBA.Trim(VBA.Left(sText, inextspace - 1))
              sText = VBA.Right(sText, VBA.Len(sText) - inextspace)
           Else
              sword = sText
              sText = ""
           End If
           
           sfirstcharacter = VBA.Left(sword, 1)
           If bJustCapitals = True Then
              If (VBA.Asc(sfirstcharacter) >= 65 And VBA.Asc(sfirstcharacter) <= 90) Then
                 ACRONYM = ACRONYM & VBA.UCase(sfirstcharacter)
              End If
           End If
           
           If bJustCapitals = False Then ACRONYM = ACRONYM & VBA.UCase(sfirstcharacter)
        Loop
    End Function
       

     

    Example

     
       

     Copyright © 2004-2007 Better Solutions Limited. All Rights Reserved.< Previous | Top | Next >