Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 4
Default Extracting 7 digit number from alphanumeric string

Hi,

I'm trying to extract a 7 digit number from an alphanumeric string (in Excel
2003)when the 7 digit number can appear anywhere in the string and the string
can also contain other numbers which I do not want. I am currently using the
formula
=1*MID(A1,MATCH(TRUE,ISNUMBER(1*MID(A1,ROW($1:$500 ),1)),0),COUNT(1*MID(A1,ROW($1:$500),1)))
which works fine when the alphanumeric string only contains the 7 digit
number I want and no other numbers. However I get errors when the string
includes other numbers.

Is there a formula I could use which would extract the 7 digit number but
which would omit all other groups of, for example, 2 digits or 10 digits?

e.g. in the string "text 1 abc1234567trial10nfy" I would like to extract
1234567.

Many thanks for any help you can give.
snowball

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 9,101
Default Extracting 7 digit number from alphanumeric string

simpley add a LEN() function. Something like this

=if(len(my formula)=7,my formula,"")


=if(len(1*MID(A1,MATCH(TRUE,ISNUMBER(1*MID(A1,ROW( $1:$500),1)),0),COUNT(1*MID(A1,ROW($1:$500),1))))= 7,1*MID(A1,MATCH(TRUE,ISNUMBER(1*MID(A1,ROW($1:$50 0),1)),0),COUNT(1*MID(A1,ROW($1:$500),1))),"")



"snowball" wrote:

Hi,

I'm trying to extract a 7 digit number from an alphanumeric string (in Excel
2003)when the 7 digit number can appear anywhere in the string and the string
can also contain other numbers which I do not want. I am currently using the
formula
=1*MID(A1,MATCH(TRUE,ISNUMBER(1*MID(A1,ROW($1:$500 ),1)),0),COUNT(1*MID(A1,ROW($1:$500),1)))
which works fine when the alphanumeric string only contains the 7 digit
number I want and no other numbers. However I get errors when the string
includes other numbers.

Is there a formula I could use which would extract the 7 digit number but
which would omit all other groups of, for example, 2 digits or 10 digits?

e.g. in the string "text 1 abc1234567trial10nfy" I would like to extract
1234567.

Many thanks for any help you can give.
snowball

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 4
Default Extracting 7 digit number from alphanumeric string

Hi Joel,

Thanks for the reply. This formula works if my string only includes a 7
digit number e.g. abc1234567def will return 1234567 but if my string is
abc1234567def1 I get an error.

Is there a way of extracting a 7 digit number while omitting any other
numbers that may appear in the alphanumeric string?

All the rows in my data will contain this 7 digit number - and I need to
extract this number for all rows - however some rows will include other
numbers which I don't want.

Thanks,
snowball


"Joel" wrote:

simpley add a LEN() function. Something like this

=if(len(my formula)=7,my formula,"")


=if(len(1*MID(A1,MATCH(TRUE,ISNUMBER(1*MID(A1,ROW( $1:$500),1)),0),COUNT(1*MID(A1,ROW($1:$500),1))))= 7,1*MID(A1,MATCH(TRUE,ISNUMBER(1*MID(A1,ROW($1:$50 0),1)),0),COUNT(1*MID(A1,ROW($1:$500),1))),"")



"snowball" wrote:

Hi,

I'm trying to extract a 7 digit number from an alphanumeric string (in Excel
2003)when the 7 digit number can appear anywhere in the string and the string
can also contain other numbers which I do not want. I am currently using the
formula
=1*MID(A1,MATCH(TRUE,ISNUMBER(1*MID(A1,ROW($1:$500 ),1)),0),COUNT(1*MID(A1,ROW($1:$500),1)))
which works fine when the alphanumeric string only contains the 7 digit
number I want and no other numbers. However I get errors when the string
includes other numbers.

Is there a formula I could use which would extract the 7 digit number but
which would omit all other groups of, for example, 2 digits or 10 digits?

e.g. in the string "text 1 abc1234567trial10nfy" I would like to extract
1234567.

Many thanks for any help you can give.
snowball

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,501
Default Extracting 7 digit number from alphanumeric string

Hi,

Try this array formula

=LOOKUP(99^99,--("0"&MID(A1,MIN(SEARCH({0,1,2,3,4,5,6,7,8,9},A1&"0 123456789")),ROW($1:$10000))))

This is an array formula which must be entered by pressing CTRL+Shift+Enter
'and not just Enter. If you do it correctly then Excel will put curly brackets
'around the formula {}. You can't type these yourself. If you edit the formula
'you must enter it again with CTRL+Shift+Enter.

Mike

"snowball" wrote:

Hi Joel,

Thanks for the reply. This formula works if my string only includes a 7
digit number e.g. abc1234567def will return 1234567 but if my string is
abc1234567def1 I get an error.

Is there a way of extracting a 7 digit number while omitting any other
numbers that may appear in the alphanumeric string?

All the rows in my data will contain this 7 digit number - and I need to
extract this number for all rows - however some rows will include other
numbers which I don't want.

Thanks,
snowball


"Joel" wrote:

simpley add a LEN() function. Something like this

=if(len(my formula)=7,my formula,"")


=if(len(1*MID(A1,MATCH(TRUE,ISNUMBER(1*MID(A1,ROW( $1:$500),1)),0),COUNT(1*MID(A1,ROW($1:$500),1))))= 7,1*MID(A1,MATCH(TRUE,ISNUMBER(1*MID(A1,ROW($1:$50 0),1)),0),COUNT(1*MID(A1,ROW($1:$500),1))),"")



"snowball" wrote:

Hi,

I'm trying to extract a 7 digit number from an alphanumeric string (in Excel
2003)when the 7 digit number can appear anywhere in the string and the string
can also contain other numbers which I do not want. I am currently using the
formula
=1*MID(A1,MATCH(TRUE,ISNUMBER(1*MID(A1,ROW($1:$500 ),1)),0),COUNT(1*MID(A1,ROW($1:$500),1)))
which works fine when the alphanumeric string only contains the 7 digit
number I want and no other numbers. However I get errors when the string
includes other numbers.

Is there a formula I could use which would extract the 7 digit number but
which would omit all other groups of, for example, 2 digits or 10 digits?

e.g. in the string "text 1 abc1234567trial10nfy" I would like to extract
1234567.

Many thanks for any help you can give.
snowball

  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 4
Default Extracting 7 digit number from alphanumeric string

Thanks Mike,

This formula extracts the first group of digits in the string regardless of
the number of digits i.e. it doesn't search for the 7 digit number within the
string.

e.g. a123bcd765421ef will extract 123 when I would like it to extract
7654321. Is there any way to extract a 7 digit number and ignore any other
set of numbers (that are not 7 digits in a row)?

Thanks.


"Mike H" wrote:

Hi,

Try this array formula

=LOOKUP(99^99,--("0"&MID(A1,MIN(SEARCH({0,1,2,3,4,5,6,7,8,9},A1&"0 123456789")),ROW($1:$10000))))

This is an array formula which must be entered by pressing CTRL+Shift+Enter
'and not just Enter. If you do it correctly then Excel will put curly brackets
'around the formula {}. You can't type these yourself. If you edit the formula
'you must enter it again with CTRL+Shift+Enter.

Mike

"snowball" wrote:

Hi Joel,

Thanks for the reply. This formula works if my string only includes a 7
digit number e.g. abc1234567def will return 1234567 but if my string is
abc1234567def1 I get an error.

Is there a way of extracting a 7 digit number while omitting any other
numbers that may appear in the alphanumeric string?

All the rows in my data will contain this 7 digit number - and I need to
extract this number for all rows - however some rows will include other
numbers which I don't want.

Thanks,
snowball


"Joel" wrote:

simpley add a LEN() function. Something like this

=if(len(my formula)=7,my formula,"")


=if(len(1*MID(A1,MATCH(TRUE,ISNUMBER(1*MID(A1,ROW( $1:$500),1)),0),COUNT(1*MID(A1,ROW($1:$500),1))))= 7,1*MID(A1,MATCH(TRUE,ISNUMBER(1*MID(A1,ROW($1:$50 0),1)),0),COUNT(1*MID(A1,ROW($1:$500),1))),"")



"snowball" wrote:

Hi,

I'm trying to extract a 7 digit number from an alphanumeric string (in Excel
2003)when the 7 digit number can appear anywhere in the string and the string
can also contain other numbers which I do not want. I am currently using the
formula
=1*MID(A1,MATCH(TRUE,ISNUMBER(1*MID(A1,ROW($1:$500 ),1)),0),COUNT(1*MID(A1,ROW($1:$500),1)))
which works fine when the alphanumeric string only contains the 7 digit
number I want and no other numbers. However I get errors when the string
includes other numbers.

Is there a formula I could use which would extract the 7 digit number but
which would omit all other groups of, for example, 2 digits or 10 digits?

e.g. in the string "text 1 abc1234567trial10nfy" I would like to extract
1234567.

Many thanks for any help you can give.
snowball



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
Change a 1,2,3 or 4 digit number to a 6 character text string Steve D Excel Worksheet Functions 3 March 28th 08 08:14 PM
Generate alphanumeric unique 4 digit values from 12 digit values mikep Excel Worksheet Functions 5 February 9th 07 08:59 PM
How do I replace last numeric string from a alphanumeric string? Christy Excel Discussion (Misc queries) 3 August 11th 06 12:17 AM
Extracting a number in a text string Pogo Excel Worksheet Functions 5 July 17th 06 06:42 PM
Extracting a number from a string and converting it into an Intege Sumeet Benawra Excel Worksheet Functions 2 May 10th 06 10:07 AM


All times are GMT +1. The time now is 01:43 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"