#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 70
Default extract number

Hi
I wondered if anyone knew the formula to extract a block of numbers in
amongst a sentace, the numbers are a a different place in each line
(mr joe bloggs 12456
mrs smith hometown county 75864
mr tom jones county potcode 44456)

the numbers always contain 6 digits.

Thank you!!
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,572
Default extract number

In your examples, the numbers are always at the end.

If that be the case, try:

=TRIM(RIGHT(SUBSTITUTE(A1," ",REPT(" ",99)),99))

If you want them to be true numbers, add the dbl unary:

=--TRIM(RIGHT(SUBSTITUTE(A1," ",REPT(" ",99)),99))


--

HTH,

RD
================================================== ===
Please keep all correspondence within the Group, so all may benefit!
================================================== ===

"Fiona" wrote in message
...
Hi
I wondered if anyone knew the formula to extract a block of numbers in
amongst a sentace, the numbers are a a different place in each line
(mr joe bloggs 12456
mrs smith hometown county 75864
mr tom jones county potcode 44456)

the numbers always contain 6 digits.

Thank you!!


  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,805
Default extract number

are they always at the end as per your example?
If yes then use
=RIGHT(A1,6)


"Fiona" wrote:

Hi
I wondered if anyone knew the formula to extract a block of numbers in
amongst a sentace, the numbers are a a different place in each line
(mr joe bloggs 12456
mrs smith hometown county 75864
mr tom jones county potcode 44456)

the numbers always contain 6 digits.

Thank you!!

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 468
Default extract number

Here's a UDF (I use) - Place this into a Standard Module

Public Function ExtractNums(c) As String
Dim i As Integer
Dim MyNums As String

'Templatebuilder
'Returning numeric value from string'
MyNums = ""
For i = 1 To Len(c)
If InStr(1, "0123456789", Mid(c, i, 1), vbTextCompare) 0 Then
MyNums = MyNums + Mid(c, i, 1)
End If
Next i
ExtractNums = MyNums
End Function




"Fiona" wrote:

Hi
I wondered if anyone knew the formula to extract a block of numbers in
amongst a sentace, the numbers are a a different place in each line
(mr joe bloggs 12456
mrs smith hometown county 75864
mr tom jones county potcode 44456)

the numbers always contain 6 digits.

Thank you!!

  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 70
Default extract number

Thank you for your message, sorry I didnt explain very well, the numbers are
always in the middle of the sentance with text either side, but the amount of
words either side varies on each line

"Sheeloo" wrote:

are they always at the end as per your example?
If yes then use
=RIGHT(A1,6)


"Fiona" wrote:

Hi
I wondered if anyone knew the formula to extract a block of numbers in
amongst a sentace, the numbers are a a different place in each line
(mr joe bloggs 12456
mrs smith hometown county 75864
mr tom jones county potcode 44456)

the numbers always contain 6 digits.

Thank you!!



  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 964
Default extract number

If the numbers are always 6 digits you can use this formula


=MID(A1,MIN(FIND({0;1;2;3;4;5;6;7;8;9},A1&"0123456 789")),6)

assuming the string is in A1

--


Regards,


Peo Sjoblom

"Fiona" wrote in message
...
Thank you for your message, sorry I didnt explain very well, the numbers
are
always in the middle of the sentance with text either side, but the amount
of
words either side varies on each line

"Sheeloo" wrote:

are they always at the end as per your example?
If yes then use
=RIGHT(A1,6)


"Fiona" wrote:

Hi
I wondered if anyone knew the formula to extract a block of numbers in
amongst a sentace, the numbers are a a different place in each line
(mr joe bloggs 12456
mrs smith hometown county 75864
mr tom jones county potcode 44456)

the numbers always contain 6 digits.

Thank you!!



  #7   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 70
Default extract number

Thank you, that's exactly what i needed !

"Peo Sjoblom" wrote:

If the numbers are always 6 digits you can use this formula


=MID(A1,MIN(FIND({0;1;2;3;4;5;6;7;8;9},A1&"0123456 789")),6)

assuming the string is in A1

--


Regards,


Peo Sjoblom

"Fiona" wrote in message
...
Thank you for your message, sorry I didnt explain very well, the numbers
are
always in the middle of the sentance with text either side, but the amount
of
words either side varies on each line

"Sheeloo" wrote:

are they always at the end as per your example?
If yes then use
=RIGHT(A1,6)


"Fiona" wrote:

Hi
I wondered if anyone knew the formula to extract a block of numbers in
amongst a sentace, the numbers are a a different place in each line
(mr joe bloggs 12456
mrs smith hometown county 75864
mr tom jones county potcode 44456)

the numbers always contain 6 digits.

Thank you!!




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 number from alphanumric Hardeep_kanwar[_2_] Excel Worksheet Functions 3 July 4th 08 09:01 PM
Extract the row number Hilton Excel Worksheet Functions 4 October 4th 07 03:17 PM
extract number smonsmo Excel Discussion (Misc queries) 5 January 24th 07 12:14 PM
Extract number from text/number string.. nastech Excel Discussion (Misc queries) 5 July 5th 06 11:21 PM
How to extract the Number from a String johnbest New Users to Excel 3 December 19th 05 06:23 PM


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

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

About Us

"It's about Microsoft Excel"