Extracting a specific number of characters from a multiline cell

bhenson

New Member
Joined
Aug 20, 2024
Messages
3
Office Version
  1. 365
Platform
  1. MacOS
Hello all,

I am attempting to reformat a list of patient contact information into something compatible with our outbound texting system. The phone number column contains multi-line cells with home, mobile, and work numbers.

I have attempted different combinations of TextBefore, TextAfter, FIND, LEN, etc., to extract the mobile number into a new column, but with little success (namely, because each cell has a slightly different type of formatting).

Column C below illustrates the multi-line cells I'm dealing with. Column D is the desired result (the first 13 characters to the left of "(Mobile)". I'll be reformatting 1,000+ rows per month, so any advice on simplifying this step would be greatly appreciated.

MobileNumberExtraction.xlsx
ABCD
1First NameLast NamePhoneMobile Number
2JohnDoe555-444-1234 (Home Phone) 555-333-1234 (Mobile)555-333-1234
3JaneDoe555-444-5678 (Home Phone) 555-333-5678 (Mobile) 555-222-5678 (Work Phone)555-333-5678
4BobDoe555-111-9876 (Mobile)555-111-9876
Sheet1
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
Welcome to the forum.

I think this might help.

=IFERROR(MID(C2,SEARCH("mobile",C2)-14,12),"no mobile")
 
Upvote 1
Solution
Hello, another option to test on a larger sample:

Excel Formula:
=MAP(C2:C4,LAMBDA(x,
LET(
a,TEXTSPLIT(x,CHAR(10)),
b,ISNUMBER(SEARCH(" (Mobile)",a)),
SUBSTITUTE(XLOOKUP(TRUE,b,a),"(Mobile)",""))))
 
Upvote 1
This single formula will spill all the mobile numbers in the specified range...
Excel Formula:
=TEXTAFTER(CHAR(10)&TEXTBEFORE(C2:C4,"(Mobile)"),CHAR(10),-1)
 
Upvote 1
try
=MID(C2,SEARCH("(mobile)",C2,1)-13,12)
example-ETAF.xlsx
ABCDEF
1First NameLast NamePhoneMobile Number
2JohnDoe555-444-1234 (Home Phone) 555-333-1234 (Mobile)555-333-1234555-333-1234
3JaneDoe555-444-5678 (Home Phone) 555-333-5678 (Mobile) 555-222-5678 (Work Phone)555-333-5678555-333-5678
4BobDoe555-111-9876 (Mobile)555-111-9876555-111-9876
Sheet2
Cell Formulas
RangeFormula
F2:F4F2=MID(C2,SEARCH("(mobile)",C2,1)-13,12)
 
Upvote 0

Forum statistics

Threads
1,221,310
Messages
6,159,176
Members
451,543
Latest member
cesymcox

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