Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3
Default HOW DO I EXTRACT NUMBERS FROM TEXT STRING

I need to extract specific numbers from a text string that varies.

For example: I need to extract the second weight from each text i.e 9.
' GW/NW: 10/9 kgs'

Can anyone help please?

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,819
Default HOW DO I EXTRACT NUMBERS FROM TEXT STRING

As in the number(s) between the second "/" and the " kgs" ?

AndyF wrote:
I need to extract specific numbers from a text string that varies.

For example: I need to extract the second weight from each text i.e 9.
' GW/NW: 10/9 kgs'

Can anyone help please?


  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,501
Default HOW DO I EXTRACT NUMBERS FROM TEXT STRING

Hi,

Not really enough information but this works for your example.

=MID(A1,FIND("/",A1,FIND("/",A1,1)+1)+1,1)

Mike

"AndyF" wrote:

I need to extract specific numbers from a text string that varies.

For example: I need to extract the second weight from each text i.e 9.
' GW/NW: 10/9 kgs'

Can anyone help please?

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,480
Default HOW DO I EXTRACT NUMBERS FROM TEXT STRING

Hi Andy

One way
=--(MID(A1,FIND("^",SUBSTITUTE(A1,"/","^",2))+1,1))

--
Regards
Roger Govier

"AndyF" wrote in message
...
I need to extract specific numbers from a text string that varies.

For example: I need to extract the second weight from each text i.e 9.
' GW/NW: 10/9 kgs'

Can anyone help please?

  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3
Default HOW DO I EXTRACT NUMBERS FROM TEXT STRING

Thanks Mike. This formula works for this example, but is there any way I can
extract any number from the text as the spacing and length of digits may
differ.

eg.

(NETT) - 68/58kgs
/NET: 338/320 KG

I only need the figure always after the '/'.

Regards,




"Mike H" wrote:

Hi,

Not really enough information but this works for your example.

=MID(A1,FIND("/",A1,FIND("/",A1,1)+1)+1,1)

Mike

"AndyF" wrote:

I need to extract specific numbers from a text string that varies.

For example: I need to extract the second weight from each text i.e 9.
' GW/NW: 10/9 kgs'

Can anyone help please?



  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3
Default HOW DO I EXTRACT NUMBERS FROM TEXT STRING

That's correct Bob!

"Bob I" wrote:

As in the number(s) between the second "/" and the " kgs" ?

AndyF wrote:
I need to extract specific numbers from a text string that varies.

For example: I need to extract the second weight from each text i.e 9.
' GW/NW: 10/9 kgs'

Can anyone help please?



  #7   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5,651
Default HOW DO I EXTRACT NUMBERS FROM TEXT STRING

On Wed, 13 Aug 2008 09:01:01 -0700, AndyF
wrote:

I need to extract specific numbers from a text string that varies.

For example: I need to extract the second weight from each text i.e 9.
' GW/NW: 10/9 kgs'

Can anyone help please?


It's pretty simple to do using a UDF utilizing Regular Expressions.

To enter the UDF,
<alt-F11 opens the VB Editor
Ensure your project is highlighted in the Project Explorer window, then
Insert/Module and paste the code below into the window that opens.

To use this, enter the formula:
=RegexSub(A1,".*/(\d+).*","$1")

The relevant pattern is

".*/(\d+).*

which separates out the digit(s) following a "/" from everything else in the
string and captures into "reference 1"

The "$1" means to substitute only what was captured in reference 1 for the
entire string.

The string needs to be all on one single line. If it is on multiple lines, we
need to change the pattern.

============================
Option Explicit

Function RegexSub(Str As String, SrchFor As String, ReplWith As String) As
String
Dim objRegExp As Object

Set objRegExp = CreateObject("vbscript.regexp")
With objRegExp
.Pattern = SrchFor
.IgnoreCase = True
.Global = True
.MultiLine = True
End With

RegexSub = objRegExp.Replace(Str, ReplWith)

End Function
==================================
--ron
  #8   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,819
Default HOW DO I EXTRACT NUMBERS FROM TEXT STRING

Then this would do that
=MID(A1,FIND("/",A1,FIND("/",A1,1)+1)+1,(FIND("
kgs",A1,1)-FIND("/",A1,FIND("/",A1,1)+1)))

Watch the word wrap, mind there is a space before the kgs

AndyF wrote:

That's correct Bob!

"Bob I" wrote:


As in the number(s) between the second "/" and the " kgs" ?

AndyF wrote:

I need to extract specific numbers from a text string that varies.

For example: I need to extract the second weight from each text i.e 9.
' GW/NW: 10/9 kgs'

Can anyone help please?




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 numbers from a string Dave Excel Worksheet Functions 3 August 7th 08 09:43 PM
extract numbers from text string thomsonpa New Users to Excel 4 December 17th 07 11:02 AM
Only extract numbers from a string of text Lost in Microbiology Excel Discussion (Misc queries) 4 October 22nd 07 03:39 PM
EXTRACT NUMBERS FROM TEXT STRING fiber_doc Excel Worksheet Functions 4 November 28th 05 06:40 PM
How do you extract numbers from a string of chacters in a cell (E. blackbeemer Excel Worksheet Functions 6 November 12th 04 09:00 AM


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