Remove ( and all after

Gregfox

Board Regular
Joined
Apr 12, 2011
Messages
120
Hi all, I'm using Excel 2007 and have a cell that looks like this [$100(-1.2%)] and would like to remove the () and all inside so that it looks like this [$100]
Thanks!
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
Hi,

Another way:


Book1
AB
1[$100(-1.2%)][$100]
Sheet108
Cell Formulas
RangeFormula
B1=LEFT(A1,FIND("(",A1)-1)&"]"
 
Upvote 0
If your ultimate goal is to fix the data within the cells the data is in, then you can do it using Excel's Replace dialog box. Select the column the data is in, press CTRL+H to bring up the Replace dialog box, put (*) in the "Find what" field, leave the "Replace with" field empty, press the "Options>>" button and make sure the "Match entire cell contents" checkbox is not checked, then click the "Replace All" button.
 
Upvote 0
Opps, It worked in a normal excel spreadsheet but (my bad)I forgot to mention I was using VBA basic, so I could not find a way to make it work in VBA basic.
Any thoughts?
 
Upvote 0
Code:
Function OnlyDollars(r As String) As String
OnlyDollars = "[$" & Val(Mid(r, 3)) & "]"
End Function
 
Last edited:
Upvote 0
Thank you, but I'm having trouble getting it to run. When I paste it into a macro I get a compiler error "expected END SUB"
 
Upvote 0
It doesn't go in a sub, it's a function. Put it outside your macro. You call it from the sub.

For example:

Code:
Function OnlyDollars(r As String) As String
OnlyDollars = "[$" & Val(Mid(r, 3)) & "]"
End Function

Sub Test()
MsgBox OnlyDollars("[$100(-1.2%)]")
End Sub
 
Upvote 0
Thank you for the help, but I’m still struggling. I did not define the problem very well.
The number in lets say A1 could be 1, 2, up to 8 digits followed by a “(“ with an number and a % sign followed by a “)”
Like this +3,067.06(0.24%) in one cell.
I wish to (using VBA) 1. Separate the number like 3067.06 without the “+” and put it in a cell.
2. Separate the 0.24% without the “(“ or “)” and put that into another cell.

The final result should look like this B1 3067.06 and B2 .024%

Sorry I wasn’t more precise.
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,284
Members
452,630
Latest member
OdubiYouth

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