Extract To Be Nick Name With Initial in The last Word

muhammad susanto

Well-known Member
Joined
Jan 8, 2013
Messages
2,077
Office Version
  1. 365
  2. 2021
Platform
  1. Windows
hi all...

how to extract this text to be the nick name like this :

nameexpected result
PT. DHARMA BERKAH SERINDITPT. DHARMA BERKAH S
PT. HALMAHERA KAYUPT. HALMAHERA KAYU
KOPERASI PETANI SAWIT MERANGKAI SEJAHTERAKOPERASI PETANI SAWIT MS
PT. INDO PATRIA PERTIWIPT. INDO PATRIA P

<tbody>
</tbody>

any help..much appreciated...

m.sa
 
Last edited:

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
If VBA is OK :
Code:
Function NickName(Name As String)
Dim ray() As String, c%, i%, intl$
ray = VBA.Split(Name, " ")
c = UBound(ray)
If c < 3 Then
    NickName = Name
Else
    For i = 3 To c
        intl = intl & Left(ray(i), 1)
    Next
    NickName = Name & " " & intl
End If
End Function

Enter as =NickName(A2)
 
Upvote 0
copy paste your code in View Code, and use =NickName (A2)..
show =#name?..

your code is UDF? or other.
 
Upvote 0
You need to put the Function in a normal module, not a sheet module.
Delete what you pasted before then :
Copy the Function
Press Alt+F11
Click Insert/Module
Paste the function to the window on the right
Assuming your names start in A2, enter in B2 and drag down =NickName(A2)
 
Upvote 0
Is your file .xlsm ? If not it needs to be.

Other possible reason : you have a module named NickName.
 
Upvote 0
@footoo
Tried it myself, it simply returns cell A2 as is !!.....no change
 
Upvote 0
Hi,

This formula solution will work for names containing One to Five words, any more than 5 will need modification.


Book1
AB
1name
2PT. DHARMA BERKAH SERINDITPT. DHARMA BERKAH S
3PT. HALMAHERA KAYUPT. HALMAHERA KAYU
4KOPERASI PETANI SAWIT MERANGKAI SEJAHTERAKOPERASI PETANI SAWIT MS
5PT. INDO PATRIA PERTIWIPT. INDO PATRIA P
6KOPERASIKOPERASI
7KOPERASI PETANIKOPERASI PETANI
Sheet159
Cell Formulas
RangeFormula
B2=LEFT(A2,FIND("^",SUBSTITUTE(A2&REPT(" ",3)," ","^",3))+1)&LEFT(TRIM(MID(SUBSTITUTE(A2," ",REPT(" ",400),4),400,100)),1)
 
Upvote 0

Forum statistics

Threads
1,214,823
Messages
6,121,777
Members
449,049
Latest member
greyangel23

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top