# Extracting Initials from Multi-Word Last Names

#### njpamdnc

##### New Member

My name is Robert, and I am a middle school math teacher who is requesting your assistance with solving a frustrating problem. I have provided you with two scenarios for extracting initials from student names.

=IF(OR(COUNTIF(B101,"*SE*"),COUNTIF(B101,"*ESL*")),A101,"") gives me the result of "BP" for Budathoki, Pranik

=IF(OR(COUNTIF(B100,"*SE*"),COUNTIF(B100,"*ESL*")),A100,"") gives me the result of "BN" for Berrocales Noriega, Jacklyz

However, I want the result for Berrocales Noriega, Jacklyz to be "BJ". In other words, I want a formula to pull the first initial from the leftmost name in a field skipping through x amount of names until the formula is ready to pull the first letter of the first name. Any assistance you can provide will be greatly appreciated.

Sincerely,
Robert

### Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.

#### kweaver

##### Well-known Member
It would help if you used XL2BB to provide some examples of how the data is structured.

#### lrobbo314

##### Well-known Member
A way using VBA.

Book1
AB
1NameInitials
2Budathoki, PranikB.P.
3Berrocales Noriega, JacklyzB.J.
Sheet4
Cell Formulas
RangeFormula
B2:B3B2=INITIALS(A2)

VBA Code:
``````Function INITIALS(s As String)
Dim sName() As String: sName = Split(s, ", ")
INITIALS = Join(Array(Left(sName(0), 1), Left(sName(1), 1), ""), ".")
End Function``````

#### sandy666

##### Banned - Rules violations
you can try Power Query
 Names Initials Budathoki, Pranik BP Berrocales Noriega, Jacklyz BJ

Power Query:
``````let
Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
Initials = Table.AddColumn(Source, "Initials", each Text.Start(Text.Select([Names],{"A".."Z"}),1)&Text.End(Text.Select([Names],{"A".."Z"}),1))
in
Initials``````

#### kweaver

##### Well-known Member

Similar to Irobbo but a formula in B2:
Code:
``=LEFT(A2,1)&"."&MID(A2,FIND(",",A2)+2,1)&"."``

#### lrobbo314

##### Well-known Member
Could use regular expressions as well.

Book1
ABC
1NameInitialsRegExp
2Budathoki, PranikB.P.B.P.
3Berrocales Noriega, JacklyzB.J.B.J.
Sheet4
Cell Formulas
RangeFormula
B2:B3B2=INITIALS(A2)
C2:C3C2=IRX(A2)

VBA Code:
``````Function IRX(s As String)
With CreateObject("VBScript.RegExp")
.Pattern = "(^\w{1})(.*?,\s)(\w{1})(.+)"
IRX = .Replace(s, "\$1.\$3.")
End With
End Function``````

#### njpamdnc

##### New Member

It would help if you used XL2BB to provide some examples of how the data is structured.
I'm sorry. I previously posted the wrong formulas. I meant to post the following formulas

=IF(COUNTIF(E101,"*,*"),LEFT(E101)&MID(E101,IFERROR(SEARCH(" ",E101),SEARCH(",",E101))+1,1),"") gives me the result of "BP" for Budathoki, Pranik

=IF(COUNTIF(E100,"*,*"),LEFT(E100)&MID(E100,IFERROR(SEARCH(" ",E100),SEARCH(",",E100))+1,1),"") gives me the result of "BN" for Berrocales Noriega, Jacklyz

However, I want the result for Berrocales Noriega, Jacklyz to be "BJ". In other words, I want a formula to pull the first initial from the leftmost name in a field skipping through x amount of names until the formula is ready to pull the first letter of the first name. Any assistance you can provide will be greatly appreciated.

#### njpamdnc

##### New Member
I'm sorry. I previously posted the wrong formulas. I meant to post the following formulas

=IF(COUNTIF(E101,"*,*"),LEFT(E101)&MID(E101,IFERROR(SEARCH(" ",E101),SEARCH(",",E101))+1,1),"") gives me the result of "BP" for Budathoki, Pranik

=IF(COUNTIF(E100,"*,*"),LEFT(E100)&MID(E100,IFERROR(SEARCH(" ",E100),SEARCH(",",E100))+1,1),"") gives me the result of "BN" for Berrocales Noriega, Jacklyz

However, I want the result for Berrocales Noriega, Jacklyz to be "BJ". In other words, I want a formula to pull the first initial from the leftmost name in a field skipping through x amount of names until the formula is ready to pull the first letter of the first name. Any assistance you can provide will be greatly appreciated.
A way using VBA.

Book1
AB
1NameInitials
2Budathoki, PranikB.P.
3Berrocales Noriega, JacklyzB.J.
Sheet4
Cell Formulas
RangeFormula
B2:B3B2=INITIALS(A2)

VBA Code:
``````Function INITIALS(s As String)
Dim sName() As String: sName = Split(s, ", ")
INITIALS = Join(Array(Left(sName(0), 1), Left(sName(1), 1), ""), ".")
End Function``````

#### njpamdnc

##### New Member
you can try Power Query
 Names Initials Budathoki, Pranik BP Berrocales Noriega, Jacklyz BJ

Power Query:
``````let
Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
Initials = Table.AddColumn(Source, "Initials", each Text.Start(Text.Select([Names],{"A".."Z"}),1)&Text.End(Text.Select([Names],{"A".."Z"}),1))
in
Initials``````
I'm sorry. I previously posted the wrong formulas. I meant to post the following formulas

=IF(COUNTIF(E101,"*,*"),LEFT(E101)&MID(E101,IFERROR(SEARCH(" ",E101),SEARCH(",",E101))+1,1),"") gives me the result of "BP" for Budathoki, Pranik

=IF(COUNTIF(E100,"*,*"),LEFT(E100)&MID(E100,IFERROR(SEARCH(" ",E100),SEARCH(",",E100))+1,1),"") gives me the result of "BN" for Berrocales Noriega, Jacklyz

However, I want the result for Berrocales Noriega, Jacklyz to be "BJ". In other words, I want a formula to pull the first initial from the leftmost name in a field skipping through x amount of names until the formula is ready to pull the first letter of the first name. Any assistance you can provide will be greatly appreciated.

#### sandy666

##### Banned - Rules violations
Any assistance you can provide will be greatly appreciated.
I don't understand
Post#4 contain your example (very poor example) and Power Query (Get&Transform) M code for that
what do you want more?
btw. there is no any worksheet formulas

I suggest you to update your profile about Excel version and OS

Replies
4
Views
1K
Replies
5
Views
2K
Replies
8
Views
686
Replies
3
Views
4K
Replies
6
Views
1K

1,127,266
Messages
5,623,722
Members
415,985
Latest member
salman101

### 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.

### Which adblocker are you using?

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

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