Get certain characters from text

LindseyMonahue0

New Member
Joined
May 27, 2019
Messages
4
Hi all,

I would like to ask for your help.

I have the following text in cell B2: 'John Smith' and I need to get only OHN starting from the left.

I've tried using the =LEFT function but it gets JOH but I need to get OHN.

Thank you excel pros.
 

LindseyMonahue0

New Member
Joined
May 27, 2019
Messages
4
Hi mumps,

I appreciate the reply -- it worked. Now new problem, the names on the columns vary in length, do you have a possible solution in mind?

Btw, in COLUMN B, listed are the First and Last Names and I just need to get the last 3 letters of the First name. ( The data contains a lot of names and splitting it would be very tideous and also, considering that some people have 2 First Names. )

Thanks so much!
 

LindseyMonahue0

New Member
Joined
May 27, 2019
Messages
4
I'm sorry what do you mean by list a representative list of names?

I may be wrong but for an example here are just few of the names:

Andrea Jones
Brent Anderson
Cornelius Waters
David Weiss
Edward John Smith
John Smith
Karen Mae Owens
Yu Xiu Ping

I just need to get the last 3 letters of each of the First Names. I've been thinking over it for hours, lol.

Btw, thank you so much mumps.
 

bosco_yip

Well-known Member
Joined
Dec 2, 2002
Messages
1,938
Office Version
2019
Platform
Windows
Assume your data put in A1:A8

In B1, copied down :

=RIGHT(LEFT(A1,-LOOKUP(1,-FIND(" ",A1,ROW($1:$99)))-1),3)

Regards
Bosco
 

MickG

MrExcel MVP
Joined
Jan 9, 2008
Messages
14,841
Try this UDF:-
Code:
Function Nam(nStr [COLOR="Navy"]As[/COLOR] String)
[COLOR="Navy"]If[/COLOR] Len(Split(nStr, " ")(0)) < 3 [COLOR="Navy"]Then[/COLOR]
    Nam = Split(nStr, " ")(0)
[COLOR="Navy"]Else[/COLOR]
    Nam = Right(Split(nStr, " ")(0), 3)
[COLOR="Navy"]End[/COLOR] If
[COLOR="Navy"]End[/COLOR] Function
To Save and Run UDF:-
Copy Function from Thread
In Your Data sheet , Click "Alt+F11",:- Vb Window appears.
From the VBWindow toolbar, Click "Insert" ,"Module":- New VBwindow appears .
Paste Code into this window.
Close Vbwindow.


In sheet, Add the "function" in a cell "B1" as :- =Nam(A1)
Click Return.
Drag UDF down for results for other Names

Regards Mick
 

LindseyMonahue0

New Member
Joined
May 27, 2019
Messages
4
Hi,

I've first tried Bosco's way and it worked like what I expected.

Thanks so much!

I'll also try rhat Mick, I'll let you know how it goes.

I appreciate everyone on this thread.

Love,
Lindsey
 

Forum statistics

Threads
1,081,727
Messages
5,360,913
Members
400,602
Latest member
newaqua

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