Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 05-19-2022, 05:05 AM
ranjan ranjan is offline Numbers Removal in a brackets Windows 10 Numbers Removal in a brackets Office 2019
Advanced Beginner
Numbers Removal in a brackets
 
Join Date: May 2021
Posts: 77
ranjan is on a distinguished road
Default Numbers Removal in a brackets

Hi,

In a document i want to remove a text within the brackets (including brackets) having symbols "+" or "-" or Both.



Ex:

Text should contains symbols "PLUS (+), MINUS (-) , BOTH (+)(-)" then remove the text within the brackets along with the brackets.

Doc Type : Docx & RTF

Input:

ABC (1255+3456-211+4332)
DEF (123+456+678)
GHI (123-456-678)

Your Help is Highly Appreciated.
Output:

ABC
DEF
GHI

Last edited by ranjan; 05-19-2022 at 05:06 AM. Reason: Added Doc Type
Reply With Quote
  #2  
Old 05-19-2022, 06:22 AM
macropod's Avatar
macropod macropod is offline Numbers Removal in a brackets Windows 10 Numbers Removal in a brackets Office 2016
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

This requires nothing more than a straightforward wildcard Find/Replace. What have you tried? I suggest you look at your own code here: https://www.msofficeforums.com/word-...-brackets.html
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 05-20-2022, 12:21 AM
ranjan ranjan is offline Numbers Removal in a brackets Windows 10 Numbers Removal in a brackets Office 2019
Advanced Beginner
Numbers Removal in a brackets
 
Join Date: May 2021
Posts: 77
ranjan is on a distinguished road
Default

Hi Macropod,

Its working fine but am facing small issue with this code. code is completely removing the text within the brackets having numbers..

Ex: If total is presented in negative value then its completely deleting the total value..

I want to delete the text having +,- or both combination withint the brackets.

Total (2345,99) This shouldnt be removed, but my code was removing the total value also, is there any possibility to remove text in the brackets having +,- or both combination.

Input:

ABC (1255+3456-211+4332)
DEF (123+456+678)
GHI (123-456-678)
TOTAL (123,456)

Output:

ABC
DEF
GHI
TOTAL (123,456)

Could you please review the below one:

Code:
Sub Test_Replace()
    With ActiveDocument.Content.Find
        .Text = "\(*\)"
        .Replacement.Text = ""
        .ClearFormatting
        .Replacement.ClearFormatting
        .MatchWildcards = True
        .Execute Replace:=wdReplaceAll
    End With
End Sub
Your Help is Highly Appreciated...
Reply With Quote
  #4  
Old 05-20-2022, 05:43 AM
macropod's Avatar
macropod macropod is offline Numbers Removal in a brackets Windows 10 Numbers Removal in a brackets Office 2016
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

You really need to invest more effort into learning how to use wildcards. See: Finding and replacing characters using wildcards

.Text = "\([!\(]@[+\-][!\(]@\)"
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply

Tags
numbers removal

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel 2019: How to display the sign of numbers in another field in brackets? Jamal NUMAN Excel 3 09-16-2021 09:44 AM
Numbers Removal in a brackets Need Wild Card for Deleting Square Brackets with Differing Numbers inside CrossReach Word 6 11-26-2019 01:02 PM
Numbers Removal in a brackets Bold numbers between square brackets jeffreybrown Word 4 02-13-2017 04:32 PM
Numbers Removal in a brackets Help with: Replace and reformat numbers inside square brackets johnbrowny Word 1 02-13-2016 06:45 PM
Numbers Removal in a brackets Find and Replace - How to insert brackets around all numbers in a doc Natedogg Word 2 05-21-2015 07:16 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 07:49 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft