Extracting Initials from Multi-Word Last Names

njpamdnc

New Member
Joined
Feb 16, 2019
Messages
34
Office Version
  1. 2007
Platform
  1. Windows
Dear Sir or Madam:

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
 

Some videos you may like

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
Joined
May 8, 2018
Messages
1,565
Office Version
  1. 365
  2. 2010
It would help if you used XL2BB to provide some examples of how the data is structured.
 

lrobbo314

Well-known Member
Joined
Jul 14, 2008
Messages
3,093
Office Version
  1. 365
Platform
  1. Windows
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
Joined
Oct 24, 2015
Messages
7,499
you can try Power Query
NamesInitials
Budathoki, PranikBP
Berrocales Noriega, JacklyzBJ

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
Joined
May 8, 2018
Messages
1,565
Office Version
  1. 365
  2. 2010

ADVERTISEMENT

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

lrobbo314

Well-known Member
Joined
Jul 14, 2008
Messages
3,093
Office Version
  1. 365
Platform
  1. Windows
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
Joined
Feb 16, 2019
Messages
34
Office Version
  1. 2007
Platform
  1. Windows

ADVERTISEMENT

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
Joined
Feb 16, 2019
Messages
34
Office Version
  1. 2007
Platform
  1. Windows
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
Joined
Feb 16, 2019
Messages
34
Office Version
  1. 2007
Platform
  1. Windows
you can try Power Query
NamesInitials
Budathoki, PranikBP
Berrocales Noriega, JacklyzBJ

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
Joined
Oct 24, 2015
Messages
7,499
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
 

Watch MrExcel Video

Forum statistics

Threads
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.
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
Top