Extracting Numbers from Alphanumeric Text

Laura2008

New Member
Joined
Jun 19, 2013
Messages
3
Hi all, I am trying to parse some alphanumeric data for inventory purposes and am having a hard time pulling out the numbers. Please see below for what I'm working with. The end goal is to see "TOTAL UNITS" ie for the first one 4, 720 (ie 60*12), 6,1, 25, 100 I have seen VBA/etc. for pulling out text, but none for numbers. PLEASE help! Thanks!
[TABLE="width: 168"]
<TBODY>[TR]
[TD]4/CA</SPAN>[/TD]
[/TR]
[TR]
[TD]60 WIPES/CN 12 CN/CA </SPAN>[/TD]
[/TR]
[TR]
[TD]6 EA/CA </SPAN>[/TD]
[/TR]
[TR]
[TD]1 CA/CA </SPAN>[/TD]
[/TR]
[TR]
[TD]25 EA/BX </SPAN>[/TD]
[/TR]
[TR]
[TD]25 EA/BX 4 BX/CA </SPAN>[/TD]
[/TR]
</TBODY><COLGROUP><COL></COLGROUP>[/TABLE]
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Hi, and welcome to the forum. :)

Add this function to a normal module:
Code:
Function GetQuantity(rIn As Range) As Double
   Dim matches
   Dim n As Long
   With CreateObject("vbscript.regexp")
      .Pattern = "[\d]+"
      .Global = True
      Set matches = .Execute(rIn.Value)
      If matches.Count = 0 Then
         GetQuantity = 0
      Else
         GetQuantity = matches(0)
         If matches.Count > 1 Then
            For n = 1 To matches.Count - 1
               GetQuantity = GetQuantity * matches(n)
            Next n
         End If
      End If
   End With

End Function
then use it like this:
=GetQuantity(A1)
 
Upvote 0
Thank you!! My only issues with this formula are for if the data name has a number in the name for example [TABLE="width: 336"]
<TBODY>[TR]
[TD]2-PLY 200 BX/CA </SPAN>[/TD]
[TD]400</SPAN>[/TD]
[/TR]
</TBODY><COLGROUP><COL span=2></COLGROUP>[/TABLE]

When in fact there are only 200 units, the tissues are just "2-ply" is that something I'll just have to go through and manually fix?
 
Upvote 0
Are there set rules that can be applied? If not, some manual intervention will be required.
 
Upvote 0

Forum statistics

Threads
1,223,236
Messages
6,170,915
Members
452,366
Latest member
TePunaBloke

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top