View Single Post
  #10   Report Post  
Ron Rosenfeld
 
Posts: n/a
Default Extract Fractional Numbers as Numbers NOT Date

On Wed, 2 Nov 2005 14:03:05 -0800, "CADManBill"
wrote:

I guess I should have been more detailed in my example.
Fact is that I have many strings similar to the example that need to be
extracted and calculated the same way. But the characters leading and
trailing the "/" differ.

More Defined Example of Strings
A1 PL3/8x5
B1 PL3/8x5 1/2
C1 PL1 1/2x3
D1 PL1 1/2x3 1/2
E1 PL13/16x15/16
On... and On...

The suggested formulas only consider One character on each side of the "/".
Basically, if the "PL" was replaced with"=" and the "x" replaced with "*" it
would look like what I an trying to accomplish.

Please excuse the name change, Earlier I was using my account at work and
now my account at home.


That explanation makes constructing a UDF pretty simple.

<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 formula, enter =EV(cell_ref) into some cell where cell_ref is a
cell you wish to evaluate as you describe (e.g. =EV(A1).

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

Function Ev(str As String) As Double
Dim Fml As String

Fml = Replace(str, "PL", "")
Fml = Replace(Fml, "x", "*")

Ev = Evaluate(Fml)
End Function
============================


--ron