Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #4  
Old 12-08-2014, 05:24 PM
macropod's Avatar
macropod macropod is offline Advanced Find & Replace help needed Windows 7 64bit Advanced Find & Replace help needed Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
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

Try the following Word macro:
Code:
Sub Demo()
Application.ScreenUpdating = False
Dim StrFnd As String, i As Long
StrFnd = "at_case_id,ca_case_ref,at_created_dt,at_audit_type,at_audit_note,at_user_id"
With ActiveDocument.Range
  With .Find
    .ClearFormatting
    .Replacement.ClearFormatting
    .Format = False
    .Forward = True
    .Wrap = wdFindContinue
    .MatchWildcards = True
    .Text = "^13([a-z]{2}[!_])"
    .Replacement.Text = "\1"
    .Execute Replace:=wdReplaceAll
    .Text = "^13{2,}"
    .Replacement.Text = "^p"
    .Execute Replace:=wdReplaceAll
    .Text = Split(StrFnd, ",")(0) & " "
    .Replacement.Text = ""
    .Execute Replace:=wdReplaceAll
    For i = 1 To UBound(Split(StrFnd, ","))
      .Text = "^13" & Split(StrFnd, ",")(i) & " "
      .Replacement.Text = ","
      .Execute Replace:=wdReplaceAll
    Next
  End With
  .InsertBefore StrFnd & vbCr
End With
Application.ScreenUpdating = True
End Sub
If you save the output as a CSV file, it should load directly into Excel. Note that this assumes there are no commas in the data.

For PC macro installation & usage instructions, see: http://www.gmayor.com/installing_macro.htm.
For Mac macro installation & usage instructions, see: http://word.mvps.org/Mac/InstallMacro.html
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Advanced Find & Replace help needed Find/Replace Wildcard Needed-Bold & Highlight rsrasc Word VBA 3 11-11-2014 03:55 PM
Advanced Find & Replace help needed New Find/Replace Wildcard Needed rsrasc Word VBA 2 11-11-2014 09:46 AM
Advanced Find & Replace help needed Find/Replace Wildcard Needed rsrasc Word VBA 4 11-11-2014 08:28 AM
Advanced search and replace for bullet points TishyMouse Word 5 02-17-2012 06:32 AM
Advanced Find & Replace help needed Advanced find and replace anno1404 Word 1 10-21-2010 03:58 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 01:56 PM.


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