Extract To Be Nick Name With Initial in The last Word

muhammad susanto

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

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

[TABLE="class: tableizer-table"]
<tbody>[TR="class: tableizer-firstrow"]
[TH]name[/TH]
[TH]expected result[/TH]
[/TR]
[TR]
[TD]PT. DHARMA BERKAH SERINDIT[/TD]
[TD]PT. DHARMA BERKAH S[/TD]
[/TR]
[TR]
[TD]PT. HALMAHERA KAYU[/TD]
[TD]PT. HALMAHERA KAYU[/TD]
[/TR]
[TR]
[TD]KOPERASI PETANI SAWIT MERANGKAI SEJAHTERA[/TD]
[TD]KOPERASI PETANI SAWIT MS[/TD]
[/TR]
[TR]
[TD]PT. INDO PATRIA PERTIWI[/TD]
[TD]PT. INDO PATRIA P[/TD]
[/TR]
</tbody>[/TABLE]

any help..much appreciated...

m.sa
 
Last edited:

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
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,223,907
Messages
6,175,300
Members
452,633
Latest member
DougMo

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