Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #2  
Old 05-13-2015, 06:43 PM
gmaxey gmaxey is offline Replacing the 2nd or 3rd instance of Text Windows 7 32bit Replacing the 2nd or 3rd instance of Text Office 2010 (Version 14.0)
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,636
gmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nice
Default

Code:
Sub ScratchMacro()
'A basic Word macro coded by Greg Maxey
Dim oRng As Word.Range
Dim lngInstance As Long, lngCount As Long
  lngCount = 0
  Set oRng = Selection.Range 'or ActiveDocument.Range
  With oRng.Find
    .Text = InputBox("Text to find:")
    lngInstance = InputBox("Sequenced number to find:")
    While .Execute
      lngCount = lngCount + 1
      If lngCount = lngInstance Then
        oRng.HighlightColorIndex = wdYellow
        Exit Sub
        oRng.Collapse wdCollapseEnd
      End If
    Wend
  End With
lbl_Exit:
  Exit Sub
End Sub
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
 

Tags
formatting text, selective replacement



Similar Threads
Thread Thread Starter Forum Replies Last Post
Replacing the 2nd or 3rd instance of Text Problem replacing text. piritzo Word 2 06-22-2013 12:50 AM
Replacing the 2nd or 3rd instance of Text Creating a plain text content control for every instance of a word or phrase RobsterCraw Word VBA 16 11-20-2012 03:25 PM
Replacing the 2nd or 3rd instance of Text Help with replacing text with wildcards sbatson5 Word 2 04-13-2012 03:49 AM
Highlight text and find next instance DrDOS Word 0 11-15-2010 04:02 PM
Replacing / editting text LisaC Word 0 02-25-2010 03:40 AM

Other Forums: Access Forums

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