Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 07-11-2015, 08:17 PM
equalizer88 equalizer88 is offline wildcard search and add (not replace) sequential numbers in front Windows 7 32bit wildcard search and add (not replace) sequential numbers in front Office 2010 32bit
Novice
wildcard search and add (not replace) sequential numbers in front
 
Join Date: Jul 2015
Posts: 15
equalizer88 is on a distinguished road
Default wildcard search and add (not replace) sequential numbers in front

My data is 1-3 lines unique code that is first element in data segment. May Not be new paragraph. First field is 1-5 digits comma and then 1 digit and comma

Original File
Line 1 123,2,text1, text2,....
Line 2 ....text 10
Line 3 145,3,text1....text 5
Line 4 156, 2, text 1...text5
Line 5 ......................text10


Line 6 ......................text15
...........
Line 7000 4160,3,text1......text4


Desired Output - Search for ([0-9],[0-9]) and insert (001) before search term and (002) before next search term

Output File
Line 1 (001) 123,2,text1, text2,....
Line 2 ....text 10
Line 3 (002) 145,3,text1....text 5
Line 4 (003) 156, 2, text 1...text5
Line 5 ......................text10
Line 6 ......................text15
Line 7 (004) 160,3,text1......text4


Maybe 1000 pages

I used https://www.msofficeforums.com/word-...ight-text.html as template and have just seach working.


Code:
Sub Wildcard_Search_Insert_Nums()
Application.ScreenUpdating = False
Options.DefaultHighlightColorIndex = wdYellow
With ActiveDocument.Content.Find
  .ClearFormatting
  .Text = "([0-9],[0-9])"
  With .Replacement
    .Text = "TEST^&XXX"
    .ClearFormatting
    .Highlight = True
  End With
  .Forward = True
  .Wrap = wdFindContinue
  .Format = True
  .MatchWildcards = True
  .Execute Replace:=wdReplaceAll
End With
Application.ScreenUpdating = True
End Sub
Need to an alternate method for search/replace with a loop line by line(?)
with n=n+1 inside loop?

Really frustrated. Would appreciate any help. Obviously can use C program to do this but want functionality for all users, not 3 machines out of hundreds that have compilers.
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Issue with wildcard search mysterytramp Word 0 05-13-2015 10:40 AM
search and replace a field containing text and numbers H28Sailor Word 6 09-11-2014 01:00 AM
Issue with Wildcard Search and Replace linusthedog Word 3 09-04-2014 03:32 PM
Where is the error in my wildcard search? Ulodesk Word 10 06-30-2014 01:46 PM
Wildcard search help. Kempston Word 0 11-13-2009 03:58 AM

Other Forums: Access Forums

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