How to remove Parenthesis with numbers and text without removing the remaining text after

Dith2228

New Member
Joined
Jul 1, 2022
Messages
14
Office Version
  1. 365
Platform
  1. Windows
I have been trying to find answer on how to remove a parenthesis with number and text inside withou the remaining words after being removed. In example

I have reviewed T09_535 (243 pages), N4057.005 (3 documents).

Result must be

I have reviewed T09_535, N4057.005.

I have tried the Find and Replace using find (*pages) and replces with space but it did not worked. Please help
 
How do i change the condition say if my cell contains (9:30am to 2:30pm) within the parenthesis but the time varies and i also need to remove that parenthesis with time inside?
Once again one example is not much to go on but this small change in the 'Pattern' line should work on that one example at least

Rich (BB code):
Sub RemoveSomeParentheses()
  Dim RX As Object
  Dim a As Variant
  Dim i As Long
 
  Set RX = CreateObject("VBScript.RegExp")
  RX.Global = True
  RX.Pattern = " *\(\d+ *(page|document|:)[^\)]*\)"
  With Range("a2", Range("A" & Rows.Count).End(xlUp))
    a = .Value
    For i = 1 To UBound(a)
      a(i, 1) = Application.Trim(RX.Replace(a(i, 1), ""))
    Next i
    .Offset(, 1).Value = a
  End With
End Sub
 
Upvote 0
Solution

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
Once again one example is not much to go on but this small change in the 'Pattern' line should work on that one example at least

Rich (BB code):
Sub RemoveSomeParentheses()
  Dim RX As Object
  Dim a As Variant
  Dim i As Long
 
  Set RX = CreateObject("VBScript.RegExp")
  RX.Global = True
  RX.Pattern = " *\(\d+ *(page|document|:)[^\)]*\)"
  With Range("a2", Range("A" & Rows.Count).End(xlUp))
    a = .Value
    For i = 1 To UBound(a)
      a(i, 1) = Application.Trim(RX.Replace(a(i, 1), ""))
    Next i
    .Offset(, 1).Value = a
  End With
End Sub
Many many thanks to you for your help. This worked perfectly. Appreciate your kindness.
 
Upvote 0
You are welcome. Thanks for the follow-up. (y)

(For future questions though, please provide enough sample data that we can see what sort of variety there might be. :) )
 
Upvote 0

Forum statistics

Threads
1,223,884
Messages
6,175,177
Members
452,615
Latest member
bogeys2birdies

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