Extracting Initials from Multi-Word Last Names

njpamdnc

New Member
Joined
Feb 16, 2019
Messages
42
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
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
It would help if you used XL2BB to provide some examples of how the data is structured.
 
Upvote 0
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
 
Upvote 0
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
 
Upvote 0
Similar to Irobbo but a formula in B2:
Code:
=LEFT(A2,1)&"."&MID(A2,FIND(",",A2)+2,1)&"."
 
Upvote 0
Solution
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
 
Upvote 0
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.
 
Upvote 0
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
 
Upvote 0
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.
 
Upvote 0
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
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,326
Members
452,635
Latest member
laura12345

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