Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #8  
Old 04-13-2021, 06:12 PM
Cendrinne's Avatar
Cendrinne Cendrinne is offline Help, FNR Wildcards Amounts in tables Cells alone Windows 10 Help, FNR Wildcards Amounts in tables Cells alone Office 2019
Competent Performer
Help, FNR Wildcards Amounts in tables Cells alone
 
Join Date: Aug 2019
Location: Montreal Quebec Canada
Posts: 200
Cendrinne is on a distinguished road
Default I see, well

Quote:
Originally Posted by macropod View Post
Since you haven't posted any code, or said anything about what you want to do with the found numbers (or anything else you're trying to find in tables), it's impossible to know for sure what the best way is of handling the task.
The thing is that it's a very long script. I've tried to combine them, but it didn't always work.

*******************************
So part 1 = Find & Replace the values below in tables, and put them in blue:

Code:
Application.ScreenUpdating = False
Dim aTbl As Table
For Each aTbl In ActiveDocument.Tables
  With aTbl.range.Find
  
    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    Selection.Find.Replacement.Font.Color = wdColorBlue
    With Selection.Find
      .Format = True
      .Forward = True
      .Wrap = wdFindStop
      .MatchWildcards = True
      .Text = "[$]{1}[0-9,.]{1;}"
      .Replacement.Text = ""
      .Execute Replace:=wdReplaceAll
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
  
    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    Selection.Find.Replacement.Font.Color = wdColorBlue
    With Selection.Find
      .Format = True
      .Forward = True
      .Wrap = wdFindStop
      .MatchWildcards = True
      .Text = "[$\(]{2}[0-9,.]{1;}"
      .Replacement.Text = ""
      .Execute Replace:=wdReplaceAll
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
  
    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    Selection.Find.Replacement.Font.Color = wdColorBlue
    With Selection.Find
      .Format = True
      .Forward = True
      .Wrap = wdFindStop
      .MatchWildcards = True
      .Text = "([0-9]{1;})"
      .Replacement.Text = "\1"
      .Execute Replace:=wdReplaceAll
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
  
    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    Selection.Find.Replacement.Font.Color = wdColorBlue
    With Selection.Find
      .Format = True
      .Forward = True
      .Wrap = wdFindStop
      .MatchWildcards = True
      .Text = "([0-9,.]{2;})"
      .Replacement.Text = "\1"
      .Execute Replace:=wdReplaceAll
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
    
    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    Selection.Find.Replacement.Font.Color = wdColorBlue
    With Selection.Find
      .Format = True
      .Forward = True
      .Wrap = wdFindStop
      .MatchWildcards = True
      .Text = "([\(][0-9]{1;}[\)])"
      .Replacement.Text = "\1"
      .Execute Replace:=wdReplaceAll
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
    
    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    Selection.Find.Replacement.Font.Color = wdColorBlue
    With Selection.Find
      .Format = True
      .Forward = True
      .Wrap = wdFindStop
      .MatchWildcards = True
      .Text = "([\(][0-9,.]{2;}[\)])"
      .Replacement.Text = "\1"
      .Execute Replace:=wdReplaceAll
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
    
    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    Selection.Find.Replacement.Font.Color = wdColorBlue
    With Selection.Find
      .Format = True
      .Forward = True
      .Wrap = wdFindStop
      .MatchWildcards = True
      .Text = "(^=){1}"
      .Replacement.Text = "\1"
      .Execute Replace:=wdReplaceAll
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
    
    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    Selection.Find.Replacement.Font.Color = wdColorBlue
    With Selection.Find
      .Format = True
      .Forward = True
      .Wrap = wdFindStop
      .MatchWildcards = True
      .Text = "([\)])([\)])"
      .Replacement.Text = "\2"
      .Execute Replace:=wdReplaceAll
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
  
    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    With Selection.Find
        .Text = ""
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindStop
        .Format = False
        .MatchCase = False
        .MatchWildcards = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
  
  End With
'Next
Next aTbl
**********************************
Part 2, If found text in Blue in tables, then Delete

Code:
Application.ScreenUpdating = False
Dim aTbl As Table
For Each aTbl In ActiveDocument.Tables
  With aTbl.range.Find
  
    Selection.Find.ClearFormatting
    Selection.Find.Font.Color = wdColorBlue
    Selection.Find.Replacement.ClearFormatting
   'Selection.Find.Replacement.Font.Color = wdColorBlue
    With Selection.Find
      .Format = True
      .Forward = True
      .Wrap = wdFindStop
      .MatchWildcards = True
      .Text = "?"
      .Replacement.Text = ""
      .Execute Replace:=wdReplaceAll
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
  
    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    With Selection.Find
        .Text = ""
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindStop
        .Format = False
        .MatchCase = False
        .MatchWildcards = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
  
  End With
'Next
Next aTbl
***********************************

Please know that I dont have programming skills YET, but I manage with what I know.

I'm sure it could be improved, but since you wanted to see my scripts, here they are

Cendrinne
Reply With Quote
 

Tags
cells, helpme, wildcards



Similar Threads
Thread Thread Starter Forum Replies Last Post
Help, FNR Wildcards Amounts in tables Cells alone Splitting Tables containing Merged Cells bpike Word VBA 7 10-28-2020 02:23 AM
Help, FNR Wildcards Amounts in tables Cells alone How do I run code on all cells in all tables? wido Word VBA 2 09-04-2019 05:32 AM
Help, FNR Wildcards Amounts in tables Cells alone Can I repeat or self-populate cells/tables? pvh PowerPoint 6 05-05-2015 03:21 PM
Tables in Powerpoint - Hiding Cells manisfeld PowerPoint 2 06-08-2014 08:17 PM
Shading in Cells in Word Tables Cindy Word Tables 1 01-04-2013 02:38 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 08:43 AM.


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