Truncating A Full Punctuated Name

DReinwald

New Member
Joined
Oct 4, 2019
Messages
3
I must, after pasting a long list of patient names, truncate to display only the first two letters of the last name, for privacy.

Beethoven, Ludwig V must become Be., Ludwig V

Doe, Jane X must become Do., Jane X

I've been using this:

=(LEFT(D66,2)&"."&","&(RIGHT(<wbr style="color: rgb(34, 34, 34); font-family: Arial, Helvetica, sans-serif; font-size: small; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); text-decoration-style: initial; text-decoration-color: initial;">
D66,8)))

but I'm more than a novice so I have to change that far right number over and over to make each name display properly.

Is a nesting of a LEFT/RIGHT the wrong approach?

Many thanks!

 

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
51,493
Office Version
365
Platform
Windows
Welcome to the Board!

Try this:
Code:
=LEFT(D67,2) & "." & MID(D67,FIND(",",D67),LEN(D67))
 
Last edited:

alansidman

Well-known Member
Joined
Feb 26, 2007
Messages
5,075
Office Version
2019
Platform
Windows
Assumes your list is in Column A =LEFT(A1,2) & "." & "," & RIGHT(A1, LEN(A1)-FIND(",",A1)) and copy down.
 

DReinwald

New Member
Joined
Oct 4, 2019
Messages
3
That works Joe4. This month's reporting will go SO much faster.

I think I see that you've done what I don't know how to do. The comma informs the spacing and LEN appears to allow for specific length.

I thank you!!
 

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
51,493
Office Version
365
Platform
Windows
Basically, with the last part, I am using the FIND function to find where the comma starts.
I am then using the MID function on the original entry, telling it to start at the comma, and then just telling to go out the number of spaces to the right.
I am using the Length of the original function for that last part, which is a bigger number than I need, but it doesn't matter if it is too big.

For example, if I had a value like "DOUBLE" in cell A1, and wanted to return from the 4th character on, I could use:
=MID(A1,4,3) to return "BLE"
however
=MID(A1,4,6) also returns "BLE" (because there is nothing after the E).

We could figure out exactly how many spaces we need for that last argument, but it isn't necessary (since we are going to the end), as long as we choose some number that will always get us there.
 

DReinwald

New Member
Joined
Oct 4, 2019
Messages
3
alansidman:

That too! Works well. Thank you both - more than I can say. Will save me a lot of reworking it.
 

alansidman

Well-known Member
Joined
Feb 26, 2007
Messages
5,075
Office Version
2019
Platform
Windows
Thanks for the feedback.
 

Forum statistics

Threads
1,082,243
Messages
5,363,972
Members
400,772
Latest member
solbebe

Some videos you may like

This Week's Hot Topics

  • populate from drop list with multiple tables
    Hi All, i have a drop list that displays data, what i want is when i select one of those from the list to populate text from different tables on...
  • Find list of words from sheet2 in sheet1 before a comma and extract text vba
    Hi Friends, Trying to find the solution on my task. But did not find suitable one to the need. Here is my query and sample file with details...
  • Dynamic Formula entry - VBA code sought
    Hello, really hope one of you experts can help with this - i've spent hours on this and getting no-where. .I have a set of data (more rows than...
  • Listbox Header
    Have a named range called "AccidentsHeader" Within my code I have: [CODE]Private Sub CommandButton1_Click() ListBox1.RowSource =...
  • Complex Heat Map using conditional formatting
    Good day excel world. I have a concern. Below link have a list of countries that carries each country unique data. [URL...
  • Conditional formatting
    Hi good morning, hope you can help me please, I have cells P4:P54 and if this cell is equal to 1 then i want row O to say "Fully Utilised" and to...
Top