Esta función definida por el usuario (UDF) sirve para extraer los acrónimos de una cadena de texto (el primer caracter de cada palabra.
Option Explicit
Public Function ACRONIMOS(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
ACRONIMOS = ACRONIMOS & VBA.UCase(sfirstcharacter)
End If
End If
If bJustCapitals = False Then ACRONIMOS = ACRONIMOS & VBA.UCase(sfirstcharacter)
Loop
End Function