View Single Post
 
Old 07-20-2021, 04:44 AM
ranjan ranjan is offline Windows 10 Office 2019
Advanced Beginner
 
Join Date: May 2021
Posts: 77
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