View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Max Max is offline
external usenet poster
 
Posts: 9,221
Default In excel, how do we pull the first letter from words in a sentence

"Deepak" wrote:
I need to assign codes to words for e.g.
Product Master would need a code like "PM"


One way is to install & use the UDF FrstLtrs below by Ron Rosenfeld ..
(UDF = user defined function)

To install the UDF:
Press Alt+F11 to go to VBE
Copy n paste the UDF into the code window (whitespace on right)
Press Alt+Q to get back to Excel

In Excel,
Assuming your data in A1 down, eg: Product Master,
put in B1: =frstltrs(A1)
which returns: PM
Copy B1 down to extract the desired results

'--------
Function FrstLtrs(str As String) As String
Dim temp
Dim i As Long

temp = Split(Trim(str))

For i = 0 To UBound(temp)
FrstLtrs = FrstLtrs & Left(temp(i), 1)
Next i

End Function
'-------

--
Max
Singapore
http://savefile.com/projects/236895
Downloads:22,500 Files:370 Subscribers:66
xdemechanik
---