#1
|
|||
|
|||
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 |
#2
|
|||
|
|||
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 |
#3
|
|||
|
|||
Its works great.....
Success! Thank you for all your help! |
Thread Tools | |
Display Modes | |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Formatting text within brackets | jimmi6jjr | Word | 4 | 10-04-2022 09:33 PM |
find and delet all text within brackets and the brackets themselves | wrdy | Word | 2 | 08-03-2017 06:55 PM |
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/Replace Brackets Problem | fatso | Word | 2 | 08-04-2011 11:34 AM |