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!
4/CA</SPAN>
60 WIPES/CN 12 CN/CA </SPAN>
6 EA/CA </SPAN>
1 CA/CA </SPAN>
25 EA/BX </SPAN>
25 EA/BX 4 BX/CA </SPAN>

<TBODY>
</TBODY><COLGROUP><COL></COLGROUP>
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
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
2-PLY 200 BX/CA </SPAN>400</SPAN>

<TBODY>
</TBODY><COLGROUP><COL span=2></COLGROUP>

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,216,623
Messages
6,131,779
Members
449,671
Latest member
OALes

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