Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 9
Default How do I copy numeric section of cell from alpha-numeric cell

Can anyone help with a formula to separate a field containing numbers and
letters into numbers per below? I only know how to use for eg =left(X,x) but
that isn't helpful as different fields have different number of numeric
charcters.


123ABC - 123
1234DEF - 1234
12GH - 12
--
ACCAguy

--
ACCAguy
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 15,768
Default How do I copy numeric section of cell from alpha-numeric cell

Based on your samples:

=LOOKUP(1E100,--MID(A1,MIN(FIND({0,1,2,3,4,5,6,7,8,9},A1&"01234567 89")),ROW(INDIRECT("1:255"))))

Leading 0s will be stripped off.

0123ABC will return 123

--
Biff
Microsoft Excel MVP


"ACCAguy" wrote in message
...
Can anyone help with a formula to separate a field containing numbers and
letters into numbers per below? I only know how to use for eg =left(X,x)
but
that isn't helpful as different fields have different number of numeric
charcters.


123ABC - 123
1234DEF - 1234
12GH - 12
--
ACCAguy

--
ACCAguy



  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1,231
Default How do I copy numeric section of cell from alpha-numeric cell

"T. Valko" wrote...
Based on your samples:

=LOOKUP(1E100,--MID(A1,MIN(FIND({0,1,2,3,4,5,6,7,8,9},A1&"01234567 89")),ROW(INDIRECT("1:255"))))

....

If the OP's cell values always begin with numerals, when would your
MIN(FIND(...)) ever return anything other than 1? If that's
representative of the OP's data, use a shorter formula.

=LOOKUP(1E+300,--LEFT(A4,seq))

where seq is a name defined as

=ROW(INDEX($1:$65536,1,1):INDEX($1:$65536,255,1))

Better to define its $1:$65536 range reference specific to a worksheet
that contains only unchanging cells.

As for other kinds of cell contents, if A1 contained xy12E-10ab, would
the OP want 12 or 0.0000000012 as the returned value? Your formula
returns the latter. Similar problems if periods or commas follow the
first set of numerals. Your formula returns the leftmost longest
substring that could be converted into a number, not the leftmost
longest string of decimal numerals. It's also fail if the leftmost
longest string of numerals had length 16 or more. Better to return
strings, then allow the OP to decide whether or not to convert them
into numbers.

To return only the leftmost longest string of decimal numerals, try
the array formula

=LEFT(MID(A1,MATCH(1,--ISNUMBER(-MID(A1,seq,1)),0),255),
MATCH(0,-ISNUMBER(-MID(MID(A1,MATCH(1,--ISNUMBER(-MID(A1,seq,1)),0),
255),seq,1)),0)-1)

If you need to do this often, consider using Laurent Longre's
MOREFUNC.XLL add-in, which provides a function named REGEX.MID which
could be used as follows.

=REGEX.MID(A1,"\d+",1)

Now a plug for OpenOffice Calc, which provides simplified regular
expressions. This could be done using

=MID(LEFT(A1;SEARCH("[^0-9]";A1;SEARCH("[0-9]";A1))-1);SEARCH("[0-9]";A1);
255)

Excel may be wonderful for numerical calculations, but its text
functions are mired in mid-1980s Lotus 123 Release 2.x equivalent
functionality. Other than supporting longer strings and adding the
useless BAHTTEXT and nearly useless CLEAN functions, there have been
NO changes in Excel's text functions (improvements, increased
functionality, just plain more of 'em) since version 3. Pathetic!
Note: Word provides support for simple regular expressions, so someone
on at least one of the Office development teams knows something about
how to implement them, but maybe the Excel team suffers from NIH.
  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 915
Default How do I copy numeric section of cell from alpha-numeric cell[OT]

Harlan Grove wrote:
Now a plug for OpenOffice Calc, which provides simplified regular
expressions. This could be done using

=MID(LEFT(A1;SEARCH("[^0-9]";A1;SEARCH("[0-9]";A1))-1);SEARCH("[0-9]";A1);
255)


[OT]

Harlan,

Yours is the first post I have noticed in this group where OpenOffice
Calc was mentioned. Do you have an article comparing OOC and Excel?
  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1,231
Default How do I copy numeric section of cell from alpha-numeric cell[OT]

smartin wrote...
....
[OT]

....
Yours is the first post I have noticed in this group where OpenOffice
Calc was mentioned. Do you have an article comparing OOC and Excel?


Only some other newsgroup responses.

Here in very brief with no claims of completeness of even
comprehensiveness.

1. OOo Calc provides regular expressions in SOME worksheet functions
and EditFind/Replace. Excel provides nothing close.

2. OOo Calc worksheet references in 3D range references can be
relative or absolute. Excel worksheet references are always absolute.

3. OOo Calc provides a FORMULA function which returns the formula in
the referenced cell. Excel provides the XLM function GET.CELL which
can do the same, among many other things, but it can't be used
directly in cell formulas standard worksheets.

4. OOo Calc accepts more than 30 arguments and more than 7 levels of
function call nesting.

5. OOo Calc's ROW and COLUMN functions NEVER return arrays, which is a
real PITA, so formulas like

=LOOKUP(1E300;1/(A1:A1001000);ROW(A1:A100))

to return the row number of the LAST cell in A1:A100 that's greater
than 1000 require references to ranges containing sequential integers
in OOo Calc.

6. More generally but without details, OOo Calc can handle only a
subset of Excel array formulas.

7. OOo Calc is A LOT SLOWER than Excel when recalculating large
workbooks.

8. OOo has poor documentation. Excel's online help has its flaws,
including some outright errors that haven't been corrected in over a
decade, but it's much more complete.

9. OOo Calc and Excel 2003 and prior provide usable UIs. Excel 2007
provides the dog's lunch UI. The greatest favor Microsoft has ever
done for a competitor is placing restrictions in the lincensing terms
of the effluent UI that prohibit its use in products competing
directly against Office.


  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 15,768
Default How do I copy numeric section of cell from alpha-numeric cell

If the OP's cell values always begin with numerals,
when would your MIN(FIND(...)) ever return
anything other than 1?


Good point. I used the first thing that came to mind thus the generic
"extract numbers" formula.

--
Biff
Microsoft Excel MVP


"Harlan Grove" wrote in message
...
"T. Valko" wrote...
Based on your samples:

=LOOKUP(1E100,--MID(A1,MIN(FIND({0,1,2,3,4,5,6,7,8,9},A1&"01234567 89")),ROW(INDIRECT("1:255"))))

...

If the OP's cell values always begin with numerals, when would your
MIN(FIND(...)) ever return anything other than 1? If that's
representative of the OP's data, use a shorter formula.

=LOOKUP(1E+300,--LEFT(A4,seq))

where seq is a name defined as

=ROW(INDEX($1:$65536,1,1):INDEX($1:$65536,255,1))

Better to define its $1:$65536 range reference specific to a worksheet
that contains only unchanging cells.

As for other kinds of cell contents, if A1 contained xy12E-10ab, would
the OP want 12 or 0.0000000012 as the returned value? Your formula
returns the latter. Similar problems if periods or commas follow the
first set of numerals. Your formula returns the leftmost longest
substring that could be converted into a number, not the leftmost
longest string of decimal numerals. It's also fail if the leftmost
longest string of numerals had length 16 or more. Better to return
strings, then allow the OP to decide whether or not to convert them
into numbers.

To return only the leftmost longest string of decimal numerals, try
the array formula

=LEFT(MID(A1,MATCH(1,--ISNUMBER(-MID(A1,seq,1)),0),255),
MATCH(0,-ISNUMBER(-MID(MID(A1,MATCH(1,--ISNUMBER(-MID(A1,seq,1)),0),
255),seq,1)),0)-1)

If you need to do this often, consider using Laurent Longre's
MOREFUNC.XLL add-in, which provides a function named REGEX.MID which
could be used as follows.

=REGEX.MID(A1,"\d+",1)

Now a plug for OpenOffice Calc, which provides simplified regular
expressions. This could be done using

=MID(LEFT(A1;SEARCH("[^0-9]";A1;SEARCH("[0-9]";A1))-1);SEARCH("[0-9]";A1);
255)

Excel may be wonderful for numerical calculations, but its text
functions are mired in mid-1980s Lotus 123 Release 2.x equivalent
functionality. Other than supporting longer strings and adding the
useless BAHTTEXT and nearly useless CLEAN functions, there have been
NO changes in Excel's text functions (improvements, increased
functionality, just plain more of 'em) since version 3. Pathetic!
Note: Word provides support for simple regular expressions, so someone
on at least one of the Office development teams knows something about
how to implement them, but maybe the Excel team suffers from NIH.



  #7   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 103
Default How do I copy numeric section of cell from alpha-numeric cell

Copy the data
Open Msword and paste

CTRl+F
Findwhat= ^$
Replace=Blank
Replace All


Hardeep kanwar

"ACCAguy" wrote:

Can anyone help with a formula to separate a field containing numbers and
letters into numbers per below? I only know how to use for eg =left(X,x) but
that isn't helpful as different fields have different number of numeric
charcters.


123ABC - 123
1234DEF - 1234
12GH - 12
--
ACCAguy

--
ACCAguy

  #8   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 5,934
Default How do I copy numeric section of cell from alpha-numeric cell

If **all** the digits in your field will **always** be in front of any
non-digits (as your examples showed), then this formula will retrieve
them...

=LEFT(A1,SUMPRODUCT(--ISNUMBER(-MID(A1,ROW($1:$9),1))))

Here, the formula assumes there will never be more than 9 digits in the
field; if there can be, then change the $9 to $99 (or, if you want, to a $
sign followed by that maximum number of possible digits). Note that this
formula returns text, which means leading zeroes will be preserved. If you
want a number returned instead (which means you don't care about leading
zeroes), then you can use this instead...

=--LEFT(A1,SUMPRODUCT(--ISNUMBER(-MID(A1,ROW($1:$9),1))))

--
Rick (MVP - Excel)


"ACCAguy" wrote in message
...
Can anyone help with a formula to separate a field containing numbers and
letters into numbers per below? I only know how to use for eg =left(X,x)
but
that isn't helpful as different fields have different number of numeric
charcters.


123ABC - 123
1234DEF - 1234
12GH - 12
--
ACCAguy

--
ACCAguy


  #9   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1,766
Default How do I copy numeric section of cell from alpha-numeric cell

Hi,

If you have typed in abc123 in cell A1, then enter the following array
formula (confirmed by Ctrl+Shift+Enter) in cell B1:

=1*MID(A1,MATCH(TRUE,ISNUMBER(1*MID(A1,ROW($1:$18) ,1)),0),COUNT(1*MID(A1,ROW($1:$18),1))+IF(ISNUMBER (MATCH(".",MID(A1,ROW($1:$18),1),0)),1,0))

Regards,

Ashish Mathur
Excel MVP
www.ashishmathur.com

"ACCAguy" wrote in message
...
Can anyone help with a formula to separate a field containing numbers and
letters into numbers per below? I only know how to use for eg =left(X,x)
but
that isn't helpful as different fields have different number of numeric
charcters.


123ABC - 123
1234DEF - 1234
12GH - 12
--
ACCAguy

--
ACCAguy


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
Prevent alpha character in numeric cell Brazil Excel Discussion (Misc queries) 2 July 21st 08 09:28 PM
subtract from numeric cell when alpha cell is occupied Keith Excel Worksheet Functions 0 March 28th 07 01:04 AM
How do I restrict entry into a cell to only alpha/numeric? SusanMurray Excel Worksheet Functions 3 May 5th 06 03:23 PM
only extract numeric value from alpha numeric cell Fam via OfficeKB.com Excel Discussion (Misc queries) 5 April 26th 06 06:49 PM
Can you ID a cell that has both Alpha AND Numeric characters? Phil Excel Worksheet Functions 5 April 18th 06 09:32 PM


All times are GMT +1. The time now is 07:19 AM.

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"