Extract To Be Nick Name With Initial in The last Word

muhammad susanto

Well-known Member
Joined
Jan 8, 2013
Messages
2,102
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:
@footoo
Tried it myself, it simply returns cell A2 as is !!.....no change
If you type the name in yourself, the code works fine. The problem is the spaces in the OP's posted text are not regular spaces (ASCII 32), rather, they are non-breaking spaces (ASCII 160) which are usually acquired by copying from the web. If you change this line of code...

ray = VBA.Split(Name, " ")

to this...

ray = VBA.Split(Replace(Name, Chr(160), " "), " ")

then the code should work fine.
 
Upvote 0

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.

Forum statistics

Threads
1,224,828
Messages
6,181,217
Members
453,024
Latest member
Wingit77

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