Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 67
Default Find and extract text from cell

I have exported address information from Quickbooks to an Excel spreadsheet
and need to know how to do the following to split out the info into other
cells. The Text to Columns feature doesn't look like its going to help.
Here's what I need:

1) Find and include everything up to the third space (" ") from the left
2) Include all information starting from the first number from the left to
the first comma from the left

Many thanks for your help.

--
David P.
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5,651
Default Find and extract text from cell

On Mon, 15 Sep 2008 17:09:00 -0700, David P.
wrote:

I have exported address information from Quickbooks to an Excel spreadsheet
and need to know how to do the following to split out the info into other
cells. The Text to Columns feature doesn't look like its going to help.
Here's what I need:


You can do it with worksheet functions:


1) Find and include everything up to the third space (" ") from the left


=LEFT(A1,FIND(CHAR(1),SUBSTITUTE(A1," ",CHAR(1),3))-1)

2) Include all information starting from the first number from the left to
the first comma from the left


The formula below must be entered as an **array** formula. Hold down
<ctrl<shift while hitting <enter. Excel will place braces {...} around the
formula.

=MID(A1,MATCH(TRUE,ISNUMBER(-MID(A1,ROW(INDIRECT(
"1:255")),1)),0),FIND(",",A1)-MATCH(TRUE,ISNUMBER(-MID(
A1,ROW(INDIRECT("1:255")),1)),0))

A more flexible solution would have you download and install Longre's free
morefunc.xll add-in from http://xcell05.free.fr


Then use these regular expression formulas:

Up to the third space:

=REGEX.MID(A1,"^(\S+\s+){2}\S+")

From first digit to first comma:

=REGEX.MID(A1,"\d[^,]+")
--ron
  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5,934
Default Find and extract text from cell

2) Include all information starting from the first number from the left
to the first comma from the left


The formula below must be entered as an **array** formula. Hold
down <ctrl<shift while hitting <enter. Excel will place braces {...}
around the formula.

=MID(A1,MATCH(TRUE,ISNUMBER(-MID(A1,ROW(INDIRECT(
"1:255")),1)),0),FIND(",",A1)-MATCH(TRUE,ISNUMBER(-MID(
A1,ROW(INDIRECT("1:255")),1)),0))


A little shorter and normally entered....

=MID(LEFT(A1,FIND(",",A1&",")-1),MIN(FIND({0,1,2,3,4,5,6,7,8,9},A1&"0123456789") ),255)

although it differs from yours at the extremes... if there is no number in
the text, my formula returns an empty string whereas yours returns an #N/A
error... if there is no comma in the text, my formula returns from the first
number to the end of the text whereas yours returns a #VALUE! error. These
differences may or may not be significant to the OP.

--
Rick (MVP - Excel)


"Ron Rosenfeld" wrote in message
...
On Mon, 15 Sep 2008 17:09:00 -0700, David P.

wrote:

I have exported address information from Quickbooks to an Excel
spreadsheet
and need to know how to do the following to split out the info into other
cells. The Text to Columns feature doesn't look like its going to help.
Here's what I need:


You can do it with worksheet functions:


1) Find and include everything up to the third space (" ") from the left


=LEFT(A1,FIND(CHAR(1),SUBSTITUTE(A1," ",CHAR(1),3))-1)

2) Include all information starting from the first number from the left to
the first comma from the left


The formula below must be entered as an **array** formula. Hold down
<ctrl<shift while hitting <enter. Excel will place braces {...} around
the
formula.

=MID(A1,MATCH(TRUE,ISNUMBER(-MID(A1,ROW(INDIRECT(
"1:255")),1)),0),FIND(",",A1)-MATCH(TRUE,ISNUMBER(-MID(
A1,ROW(INDIRECT("1:255")),1)),0))

A more flexible solution would have you download and install Longre's free
morefunc.xll add-in from http://xcell05.free.fr


Then use these regular expression formulas:

Up to the third space:

=REGEX.MID(A1,"^(\S+\s+){2}\S+")

From first digit to first comma:

=REGEX.MID(A1,"\d[^,]+")
--ron


  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5,651
Default Find and extract text from cell

On Tue, 16 Sep 2008 04:23:54 -0400, "Rick Rothstein"
wrote:

A little shorter and normally entered....

=MID(LEFT(A1,FIND(",",A1&",")-1),MIN(FIND({0,1,2,3,4,5,6,7,8,9},A1&"0123456789") ),255)

although it differs from yours at the extremes... if there is no number in
the text, my formula returns an empty string whereas yours returns an #N/A
error... if there is no comma in the text, my formula returns from the first
number to the end of the text whereas yours returns a #VALUE! error. These
differences may or may not be significant to the OP.


The REGEX formulas I posted likewise return empty strings if the pattern
doesn't match.

The issue, of course, arises if the specification the OP posted turns out not
to be 100% accurate. For me, the regex expressions will be easier to change
and test.
--ron
  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 67
Default Find and extract text from cell

Many thanks to you both.
--
David P.


"Ron Rosenfeld" wrote:

On Tue, 16 Sep 2008 04:23:54 -0400, "Rick Rothstein"
wrote:

A little shorter and normally entered....

=MID(LEFT(A1,FIND(",",A1&",")-1),MIN(FIND({0,1,2,3,4,5,6,7,8,9},A1&"0123456789") ),255)

although it differs from yours at the extremes... if there is no number in
the text, my formula returns an empty string whereas yours returns an #N/A
error... if there is no comma in the text, my formula returns from the first
number to the end of the text whereas yours returns a #VALUE! error. These
differences may or may not be significant to the OP.


The REGEX formulas I posted likewise return empty strings if the pattern
doesn't match.

The issue, of course, arises if the specification the OP posted turns out not
to be 100% accurate. For me, the regex expressions will be easier to change
and test.
--ron



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Extract a specific portion of text as new cell value Craig860 Excel Discussion (Misc queries) 6 March 20th 08 05:06 PM
Extract text in middle using Mid and Find or Search Karin Excel Discussion (Misc queries) 5 January 24th 08 08:01 AM
HOW TO EXTRACT CELL REFERENCE AS TEXT FROM NAMED RANGE romelsb Excel Worksheet Functions 0 November 3rd 06 09:49 PM
extract number and use in formula from text & numbers in cell ivory_kitten Excel Worksheet Functions 3 July 14th 06 05:38 AM
formula to extract partial content (text) of cell milano Excel Discussion (Misc queries) 3 November 9th 05 04:57 PM


All times are GMT +1. The time now is 12:09 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"