Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 09-20-2018, 01:07 AM
Yotem189
Guest
 
Posts: n/a
Default Find and Replace Numbers Macro VBA in Microsoft Word


Hi all,

I'm trying to create a macro that will replace numerical values in only yellow highlighted text into 'x' for each character.
At the moment my code only works for all highlighted texts not just yellow.
How can I change this to make it only identify yellow highlighted texts?

Any help is greatly appreciated!


Code:
Application.ScreenUpdating = False

Lookfor = "1234567890"
Dim i As Long
For i = 1 To Len(Lookfor)
  Lookchar = Mid$(Lookfor, i, 1)
  Selection.Find.ClearFormatting
  Selection.Find.Replacement.ClearFormatting
  With Selection.Find
    .Text = Lookchar
    .Replacement.Text = "x"
    .Forward = True
    .Wrap = wdFindContinue
    .Format = False
    .MatchCase = True
    .MatchAllWordForms = False
    .Highlight = True
End With
  Selection.Find.Execute Replace:=wdReplaceAll
Next

Application.ScreenUpdating = True
End Sub
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Find and Replace Numbers Macro VBA in Microsoft Word Infinite loops occurring in find and replace functions in word macro Thefirstfish` Word VBA 5 04-06-2017 07:18 PM
Find and Replace Numbers Macro VBA in Microsoft Word Need Macro for Find and Replace, Inserting logo in Ms-Word. Aswinraj Word VBA 1 06-05-2016 04:33 PM
Find and Replace Numbers Macro VBA in Microsoft Word Macro to replace Image, Numbers in Table and in multiple protected word document balaji Word VBA 10 03-24-2016 02:11 AM
Find and replace BETWEEN numbers WordUser2015 Word 4 12-19-2014 02:09 PM
Find and Replace Numbers Macro VBA in Microsoft Word Word VBA Macro to Find and Replace based on the Alt Text of an Image bennymc Word VBA 1 01-27-2014 04:23 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 08:41 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