Solved

Simplifying Excel Formula

Posted on 2016-09-01
12
76 Views
Last Modified: 2016-09-01
Hi all,

I have an excel formula that takes the contents of a name in column B, then does this:

- Extracts the first letter of the Last name
- Extracts the first letter of the First name
- Extracts the first letter of the Middle name

It'll then attach the date in Column A to create a String, then places it in Column C (please see attached below).

 Screen
Here is the formula:

=iferror(LEFT(B81,1)&MID(B81,FIND(",",B81)+2,1)&LEFT(TRIM(RIGHT(SUBSTITUTE(B81," ",REPT(" ",LEN(B81))),LEN(B81))),1)&TEXT(A81,"mmddyyyy"),"")

Can someone simplify it so that we can disregard the Middle Name altogether? I just want the first char of Last, first char of First, then combine the date.

Thanks in advance.
0
Comment
Question by:Go-Bruins
  • 5
  • 5
  • 2
12 Comments
 
LVL 33

Expert Comment

by:Rob Henson
ID: 41780082
To ignore the Middle Name just remove the section in bold:

=iferror(LEFT(B81,1)&MID(B81,FIND(",",B81)+2,1)&LEFT(TRIM(RIGHT(SUBSTITUTE(B81," ",REPT(" ",LEN(B81))),LEN(B81))),1)&TEXT(A81,"mmddyyyy"),"")

Leaving:
=IFERROR(LEFT(B81,1)&MID(B81,FIND(",",B81)+2,1)&TEXT(A81,"mmddyyyy"),"")
0
 
LVL 30

Expert Comment

by:Subodh Tiwari (Neeraj)
ID: 41780096
Try this....

=IFERROR(LEFT(B81,1)&LEFT(TRIM(RIGHT(SUBSTITUTE(B81," ",REPT(" ",LEN(B81))),LEN(B81))),1)&TEXT(A81,"mmddyyyy"),"")

Open in new window

0
 
LVL 30

Expert Comment

by:Subodh Tiwari (Neeraj)
ID: 41780102
Sorry Rob! Didn't refresh the page before posting.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 30

Expert Comment

by:Subodh Tiwari (Neeraj)
ID: 41780104
I just want the first char of Last, first char of First, then combine the date.
In that case try this....
=IFERROR(LEFT(TRIM(RIGHT(SUBSTITUTE(B81," ",REPT(" ",LEN(B81))),LEN(B81))),1)&LEFT(B81,1)&TEXT(A81,"mmddyyyy"),"")

Open in new window

0
 
LVL 33

Expert Comment

by:Rob Henson
ID: 41780116
Neeraj - that gives first character of First and First Character of Middle.

Assuming that the text is in format:
Last, First Middle

Sample given was Aardvark, Ben Hur
Result was ABH & Date
Question states
- Extracts the first letter of the Last name  = A from Aardvark
- Extracts the first letter of the First name  = B from Ben
- Extracts the first letter of the Middle name = H from Hur

Therefore new result should be only AB & Date
0
 
LVL 33

Accepted Solution

by:
Rob Henson earned 400 total points
ID: 41780133
In case there are leading spaces or multiple spaces between Last and First, try this:

=IFERROR(LEFT(TRIM(B81),1)&MID(TRIM(B81),FIND(",",TRIM(B81))+2,1)&TEXT(A81,"mmddyyyy"),"")

Thanks
Rob
0
 
LVL 30

Assisted Solution

by:Subodh Tiwari (Neeraj)
Subodh Tiwari (Neeraj) earned 100 total points
ID: 41780137
Ah.. didn't pay that much attention to it. My bad.
Thanks for pointing this out.
0
 
LVL 33

Expert Comment

by:Rob Henson
ID: 41780143
Maybe a literal translation mistake. Aardvark is indeed the first name in the cell and Hur is the last name in the cell.
0
 
LVL 30

Expert Comment

by:Subodh Tiwari (Neeraj)
ID: 41780148
Only OP can tell what's the case here. :)
0
 

Author Closing Comment

by:Go-Bruins
ID: 41780152
Rob - your last formula did the trick. Thanks to both of you!
0
 
LVL 33

Expert Comment

by:Rob Henson
ID: 41780155
Glad to help.

Also good to be a member of EE to enter into discussions over interpretation of requirements and solutions.
0
 

Author Comment

by:Go-Bruins
ID: 41780156
Just to clarify:

"Aardvark" is the last name.
"Ben" is the first name.
"Hur" is the middle name.

Thanks again.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question