#1
|
|||
|
|||
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 |
#2
|
||||
|
||||
Cross-posted (and answered BEFORE posting here) at: http://www.vbaexpress.com/forum/show...mbers&p=384148
For cross-posting etiquette, please read: http://www.excelguru.ca/content.php?184 It really is quite rude of you not to even acknowledge the assistance you've received elsewhere.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#3
|
|||
|
|||
Solved in another forum by macropod- http://www.vbaexpress.com/forum/show...mbers&p=384148
Moderators please consider deleting this thread as it seems to breach the cross-posting rule. |
#4
|
||||
|
||||
Kindly familiarise yourself with the rule @ VBAExpress and the general cross-posting etiquette expected in the link I gave you here.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Infinite loops occurring in find and replace functions in word macro | Thefirstfish` | Word VBA | 5 | 04-06-2017 07:18 PM |
Need Macro for Find and Replace, Inserting logo in Ms-Word. | Aswinraj | Word VBA | 1 | 06-05-2016 04:33 PM |
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 |
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 |