You are on page 1of 46

he tutorial

shows
how to
extract
number
from
various
text
strings in
Excel by
using
formulas
and the
Extract
tool.

Except
using
the Find
function
in Excel,
When it comes
actually
to extracting
you can
part of a text
create
string of a given
your
length, Excel
own
provides
search
three Substring
box for
functions (Left,
searchin
Right and Mid)
g
to quickly
needed
handle the task.
values
When it comes
easily.
to extracting a
number from an
This
alphanumeric article
string, Microsoft will
Excel provides… show
nothing. you two
methods
to create
your
own
search
Create
your
own
search
box with
Conditio
nal
Formatti
ng to
highlight
all
searche
d results

To get a
number
from a
string in
Excel, it
takes a
little
ingenuity, Create
a bit of your
patience, own
search
and a box with
bunch of formulas
different to list all
functions searche
d results
nested
into each
other. Or,
you can
run the
Extract
tool and
have the
Easily
search
(find
and
replac
e)
Extract texts
number from in all
the right of a open
string
workb
ooks
or
certai
n
works
heets
The Adv
anced
Find and
Replace
function
of Kutoo
ls for
Excel ca
n help
you
easily
search
or find
Get number
and
from the left
replace
of a string
certain
content
in all
open
workboo
ks as
well as
multiple
specified
workboo
ks. Dow
nload
the full
Extract
number from
anywhere in a
string
Kutools
for
Excel:
with
more
than 200
handy
Excel
How to extract
add-ins,
number from
free to
string with
try with
Ultimate Suite
no
limitatio
n in 60
days. Do
wnload
the free
trial
Now!

Recom
mende
d
Produc
tivity
Tools
For
Excel/
Office
How
Office
to Tab: B
ring
extra tabbed
editing

ct to
Excel
and
num other
Office
ber softwa
re, just
from like
Chrom
e,
the Firefo
x and
end Safari.
30-day
of Unlimi
ted

text Free
Trial

strin
Kutool
s for
Excel:
300
powerf
ul
featur
es
make
Excel
much
easy
and
increa
se
produ
ctivity
immed
iately.
60-day
Unlimi
ted
Free
Trial
When you
have a
column of
alphanum
eric strings
where
number
always
comes
after text,
you can
use one of
the
following
formulas
to get it.

Creat
e Your
Own
Search
Box
With
Condit
ional
Forma
tting
To
Highli
ght All
Search
ed
Result
s
Importan
t note! In
the below
formulas,
the
extraction
is
performe
d with
the RIGH
T and LE
FT functi
ons,
which
belong to
the
category
of Text
functions.
The
output of
these

Formu
la 1.
Get
numb
er
from
the
right
of a
string
To extract
number
from a
'text-
number'
string, the
first thing
you need Amazing!
Using
to know is Efficient
where to Tabs In
start the Excel Like
Chrome,
extraction.
Firefox
So, let's And
determine Safari!
the
position of
the first
digit with
this
generic
formula:

You
can do
as
follows
to
MIN(SEA create
RCH({0, your
1,2,3,4 own
,5,6,7, search
box by
8,9},ce using
ll &"012 the
3456789 Conditi
")) onal
Format
ting
functio
n in
Excel.
1.
Select
the
range
with
data
you
need
to
search
by the
search
box,
then
click C
onditio
nal
Forma
tting >
New
Rule u
nder
the Ho
me tab
. See
screen
shot:
We will
dwell on
the
formula's
logic a bit
later. For
now,
simply
replace ce
ll with a
reference
to the cell
containing
the
original
string (A2
in our
case), and
enter the
formula in
any empty
cell in the
2. In
the Ne
w
Forma
tting
Rule di
alog
box,
you
need
to:
2.1)
Select
Use a
formul
a to
deter
mine
which
1
cells
to
format
option
in
the Sel
ect a
Rule
Type b
ox;

2.2)
Enter
formul
a =ISN
UMBE
R(SEA
RCH($
B$2,A5
)) into
the For
mat
values
where
this
formul
a is
true bo
x;
Although
the
formula 2.3)
contains Click
an array the For
mat bu
constant,
tton to
it's a specify
regular a
formula highlig
hted
completed
color
in the for the
usual way search
by ed
value;
pressing
the Enter
key.
2.4)
Click
the OK
button
.
Once the
position of
the first
digit is
determine
d, you use
the RIGHT
function to
extract the
number.
To find out
how many
characters
should be
extracted,
you
subtract
the
position of
the first
digit from
the total
Notes:
1. In
the
formul
a,
$B$2
is a
blank
cell
you
need
to use
it as a
search
box,
and A5
is the
first
cell of
your
selecte
d
range
you
need
to
search
values
2. The
formul
a is not
case-
sensitiv
e.
Now
the
search
box is
create
d,
when
typing
search
Where A2 criteria
is the into the
original search
box B2
string and
and
B2 is the press
position of the
the first Enter
key, all
digit. matche
d
values
in the
specifi
ed
range
are
search

The
following
screensho
t shows
the
results:
To
eliminate
the helper
column
containing
the
position of
the first
digit, you
can
embed the
MIN
formula
directly in
the RIGHT
function
like this:

To force
the
formula to
return
a number
rather than
a numeric
string,
nest it into
the
VALUE
function:

#VALUE!
How the
position
of the
1st digit
is
calculat
ed

We supply
the array
constant
{0,1,2,3,4,
5,6,7,8,9}
in
the find_te
xt argume
nt of the
SEARCH
function,
so that the
formula
searches
for each
element of
the array
within the
original
string and
returns
their
The MIN
function
processes
the
resultant
array and
returns the
smallest
value,
which
correspon
ds to the
position in
of the first
digit in the
original
string.
Additionally, we
use a special
construction
(A2&"01234567
89") to
concatenate
every possible
number with the
original string. In
situations when
a certain
number in the
array constant is
not found within
the source
string, this
construction
acts
like IFERROR for
cing the formula
to return a
"fake" position
equal to the
string length +1
or more chars.
As the result, if
the original
string does not
To make
things
easier to
understan
d, let's see
how the
formula
works out
for a
specific
cell, say
A2. That
cell
contains
the text
string
"ECDAA-
05", for
which the
SEARCH
function
returns the
0 is the
1st eleme
nt of the
array
constant
and the
7th chara
cter in
the
original
string,
therefore
the first
item of
the
resulting
array is
"7".
5 is the
6th eleme
nt of the
array
constant
and the
8th chara
cter in
the
original
string, so
the sixth
item of
the
resulting
array is
"8".
No other
item of
the array
constant
is found
in cell A2,
and
therefore
the other
8 items of
the
resulting
array
represent
the
positions
of
correspo
nding
digits in
the
concaten
Since 7 is
the
smallest
value in
the
resulting
array, the
MIN
function
returns it,
so we get
the
position of
the first
digit (0) in
original
string.

Formu
la 2.
Pull
numb
er
from
the
right
of a
string
Another
way to
extract
number
from the
end of a
string is by
using this
generic
formula:

RIGHT(c
ell ,SUM
(LEN(ce
ll ) -
LEN(SUB
STITUTE
(cell ,
{"0","1
","2","
3","4",
"5","6"
,"7","8
","9"},
""))))
With the
original
text string
in A2, you
enter the
below
formula in
B2 or any
other
empty cell
in the
same row,
and then
copy it
down the
column:

You might also like