Thursday, June 7, 2012

libreoffice macro basic full name in to name with initials format

1) Open macro organizer
Tools > Macros > Organize Macros > Libreoffice basic...

2) Select and edit Main located at
My Macros > Standard > Module1 > Main

3) Add following function to the end of the file
Function FullnameInitialed(fullname)
Dim out as String
Dim arr() As String
arr = Split(fullname, " ")
For lngPosition = LBound(arr) To UBound(arr)
word = arr(lngPosition)
If UBound(arr) = lngPosition Then
out = out & " " & word
    out = out & " " & LEFT(word,1)
End If        
Next lngPosition
End Function 

4) Save and close the macro editor and get back to spreadsheet and now you can use this function as any other function (like SUM function)


No comments:

Post a Comment