Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 07-20-2021, 04:44 AM
ranjan ranjan is offline Find and delet all text within brackets and the brackets themselves Windows 10 Find and delet all text within brackets and the brackets themselves Office 2019
Novice
Find and delet all text within brackets and the brackets themselves
 
Join Date: May 2021
Posts: 10
ranjan is on a distinguished road
Default Find and delet all text within brackets and the brackets themselves

Hi,

I had copied a macro from this forum to delete the text within the brackets & themselves.

Its works exactly but am having some limitations to this macro...

if i run this macro, the values which are in negative signs also get deleted... actually it should nt get deleted.

Input :

I. OBJECT (ct.301+302+303+321+322+/-308+323+326+327+328+331+332+341+345
+346+347+/-348+351+354+356+357+358+361+/-368+371+/-378+381+/-388+4091-
391- 392-393-394-395-396-397-398 - din ct.4428)

II.HELLO (ct.267*-296*+4092+411+413+418+425+4282+431**+437**+4382+44 1**+4424+din


ct.4428**+444**+445+446**+447**+4482+451**+453**+4 56**+4582+461+4662
+473** - 491 - 495 - 496+5187)

III. GREAT (ct.501+505+506+507+din ct.508+5113+5114-591-595-596-598)


IV. Total (150) (180.25)

Output:

I. OBJECT

II.HELLO


III. GREAT

Here No . IV should remain same but while running a macro the sum total was deleting automatically...

can you please modify the code according to it.

Here it should be reflect on the brackets having numbers with text & special characters (*,+,., /, \ ,-,**, @@, ***, ##) ex (ct.12+/-6+124*+311)

When there is only numbers in the bracket its should not get reflected. ex(100.38.00)

Code:

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
  #2  
Old 07-21-2021, 05:08 PM
Peterson Peterson is offline Find and delet all text within brackets and the brackets themselves Windows 10 Find and delet all text within brackets and the brackets themselves Office 2019
Advanced Beginner
 
Join Date: Jan 2017
Posts: 62
Peterson is on a distinguished road
Default

It looks like every set of numbers in parentheses that you need to delete begins with ct., so you can delete those sets while leaving your totals with the following code:
Code:
Sub Test_Replace()
    With ActiveDocument.Content.Find
        .Text = "\(ct.*\)"
        .Replacement.Text = ""
        .ClearFormatting
        .Replacement.ClearFormatting
        .MatchWildcards = True
        .Execute Replace:=wdReplaceAll
    End With
End Sub
Reply With Quote
  #3  
Old 07-22-2021, 01:06 AM
ranjan ranjan is offline Find and delet all text within brackets and the brackets themselves Windows 10 Find and delet all text within brackets and the brackets themselves Office 2019
Novice
Find and delet all text within brackets and the brackets themselves
 
Join Date: May 2021
Posts: 10
ranjan is on a distinguished road
Default

Its works great.....

Success! Thank you for all your help!
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Find and delet all text within brackets and the brackets themselves Formatting text within brackets jimmi6jjr Word 3 05-17-2020 02:06 AM
Find and delet all text within brackets and the brackets themselves find and delet all text within brackets and the brackets themselves wrdy Word 2 08-03-2017 06:55 PM
Find and delet all text within brackets and the brackets themselves Find and Replace - How to insert brackets around all numbers in a doc Natedogg Word 2 05-21-2015 07:16 AM
Microsoft Word macro to find text, select all text between brackets, and delete helal1990 Word VBA 4 02-05-2015 03:52 PM
Find and delet all text within brackets and the brackets themselves Find/Replace Brackets Problem fatso Word 2 08-04-2011 11:34 AM

Other Forums: Access Forums - Senior Forums

All times are GMT -7. The time now is 01:30 AM.


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