Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #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
  #2  
Old 09-20-2018, 01:19 AM
macropod's Avatar
macropod macropod is offline Find and Replace Numbers Macro VBA in Microsoft Word Windows 7 64bit Find and Replace Numbers Macro VBA in Microsoft Word Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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]
Reply With Quote
  #3  
Old 09-20-2018, 02:34 AM
Yotem189
Guest
 
Posts: n/a
Default

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.
Reply With Quote
  #4  
Old 09-20-2018, 05:55 AM
macropod's Avatar
macropod macropod is offline Find and Replace Numbers Macro VBA in Microsoft Word Windows 7 64bit Find and Replace Numbers Macro VBA in Microsoft Word Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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]
Reply With Quote
Reply

Thread Tools
Display Modes


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 12:54 PM.


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