Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #11  
Old 04-13-2021, 07:50 PM
Guessed's Avatar
Guessed Guessed is offline Help, FNR Wildcards Amounts in tables Cells alone Windows 10 Help, FNR Wildcards Amounts in tables Cells alone Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 4,176
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

Cendrinne

Edit: I see that Paul also tidied up the code while I was posting. I think the wdFindStop could be a problem as the range may collapse as you progress through the code. It is possibly better to use wdFindContinue if you are encountering issues.

You should be able to clean up your code considerably. You started by defining a range and then completely ignored it by using Selection instead. Try this cleanup on your Part 1 code and study it before applying the same principles to your Part 2
Code:
  Application.ScreenUpdating = False
  Dim aTbl As Table, rngTable As Range
  For Each aTbl In ActiveDocument.Tables
    Set rngTable = aTbl.Range
    With rngTable.Find
      .ClearFormatting
      .Replacement.ClearFormatting
      .Replacement.Font.Color = wdColorBlue
      .Format = True
      .Forward = True
      .Wrap = wdFindContinue
      .MatchWildcards = True
      
      .Text = "[$]{1}[0-9,.]{1;}"
      .Replacement.Text = ""
      .Execute Replace:=wdReplaceAll
    
      .Text = "[$\(]{2}[0-9,.]{1;}"
      .Execute Replace:=wdReplaceAll
    
      .Text = "([0-9]{1;})"
      .Replacement.Text = "\1"
      .Execute Replace:=wdReplaceAll
        
      .Text = "([0-9,.]{2;})"
      .Execute Replace:=wdReplaceAll
      
      .Text = "([\(][0-9]{1;}[\)])"
      .Execute Replace:=wdReplaceAll
        
      .Text = "([\(][0-9,.]{2;}[\)])"
      .Execute Replace:=wdReplaceAll
        
      .Text = "(^=){1}"
      .Execute Replace:=wdReplaceAll
    
      .Text = "([\)])([\)])"
      .Replacement.Text = "\2"
      .Execute Replace:=wdReplaceAll
    End With
  Next aTbl
Another tip is to not be so liberal with your use of Application.ScreenUpdating = False
It is better to not do that until your code is fully debugged as it stops you from seeing what is going on as your macro runs and makes life difficult if the code fails at any point before you turn it on again.
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
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 09:24 PM.


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