Who Wants a Challenge?

Laura2008

New Member
Joined
Jun 19, 2013
Messages
3
Hi all-
I am in the middle of a HUGE dataset and having some trouble calculating the correct units of measure value so I can accurately calculate "net cost". An example is below:

Unit Amount: 50 EA/BX 4 BX/CA
Unit of Measure: BX
Cost per Unit: $9.40


I have a code that I have used to parse out and calculate the total units (see below); but I don't know if there is a way to edit this so that I can accurately get the correct amount of "EA" for the Unit of Measure indicated.
(For example: my code correctly gives me the 100 EA p/ CA, but I need to parse out the 50 EA/BX because BX is my Unit of measure). IF ANYONE can help that would be greatly appreciated. Thank you!

This is the VBA Code I currently have to parse my alphanumeric data (ie 50 ea/bx 4 bx/ca)

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
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off

Forum statistics

Threads
1,223,236
Messages
6,170,906
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