Link to home
Start Free TrialLog in
Avatar of sandramac
sandramac

asked on

Remove parenthesis from data

I have data in cell A47, that has a parenthesis at the end.  I need to extract just the numbers and leave out the ")"

Example is  77,965.52)  I need a formula to give me 77,965.52.
Avatar of Bill Prew
Bill Prew

Is there other information in the cell?


»bp
Here is a solution using the same regex function I provided in your prior question.  It finds the number at the end of the cell content and then removes the paren.

EE29141238.xlsm


»bp
If A47 only contains the string 77,965.52), you may try Substitute formula to remove the ")" from the cell.

=SUBSTITUTE(A47,")","")

Open in new window


If A47 contains some other text as well along with the number, you may place this UDF on a standard module like Module1.

Function getNumber(str As String)
With CreateObject("VBScript.RegExp")
    .Global = False
    .Pattern = "\d+\,?\d+\.?\d{2}"
    If .test(str) Then
        getNumber = .Execute(str)(0)
    End If
End With
End Function

Open in new window

And then use this formula to get the number from the string in A47.
=getNumber(A47)

Open in new window

GetNumber.xlsm
This question needs an answer!
Become an EE member today
7 DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.