VBA Solution To Extract Initials From A text String Name

Ark68

Well-known Member
Joined
Mar 23, 2004
Messages
4,564
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
I have a text string (an individual's name ... surname, given) in B16 eg. "Martin, Allan"
I am looking for a VBA solution to extract the individual's initials to be put in cell C16.

In this example ... C16 = "AM"

I know how to get the "M", but I am not sure how to isolate the first letter after the space.
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
Not sure how to do this with VBA, but this regular formula will work for you, provided here are just 2 names...
A​
B​
1​
Martin, AllanAM
B1=MID(A1,FIND(" ",A1)+1,1)&LEFT(A1,1)
perhaps you can adapt that to your code, although a regular formula will do just as well.
 
Upvote 0
Hello Ford, thank you. That was much simpler than I had anticipated. Thank you!
 
Upvote 0
Code:
Dim d() As String
r = "Martin, Allan"
d() = Split(r, ", ")
i = Left(d(1), 1) & Left(d(0), 1)
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,143
Messages
6,123,277
Members
449,093
Latest member
Vincent Khandagale

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