Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #15  
Old 12-10-2018, 12:52 AM
macropod's Avatar
macropod macropod is offline Need to repeat macro for multiple times Windows 7 64bit Need to repeat macro for multiple times Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,515
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:
Code:
Sub Demo()
Application.ScreenUpdating = False
Dim StrPfx As String, StrSfx As String, StrMid As String, StrTmp As String
Dim i As Long, j As Long, k As Long
StrPfx = "\<irf fnf=“": StrSfx = "”/\>"
With ActiveDocument.Range
  With .Find
    .ClearFormatting
    .Replacement.ClearFormatting
    .Text = "(" & StrPfx & "[A-Z]@)[0-9]@" & StrSfx & "-\1[0-9]@" & StrSfx
    .Replacement.Text = ""
    .Forward = True
    .Wrap = wdFindStop
    .Format = False
    .MatchWildcards = True
    .Execute
  End With
  Do While .Find.Found
    StrTmp = Split(Split(.Text, Replace(StrSfx, "\", ""))(0), "“")(1)
    StrMid = StrTmp
    For i = 1 To Len(StrTmp)
      If Right(StrMid, 1) Like "[0-9]" Then
        StrMid = Left(StrMid, Len(StrMid) - 1)
      End If
    Next
    i = CLng(Replace(StrTmp, StrMid, ""))
    StrTmp = Split(Split(.Text, Replace(StrSfx, "\", ""))(1), "“")(1)
    StrMid = StrTmp
    For j = 1 To Len(StrTmp)
      If Right(StrMid, 1) Like "[0-9]" Then
        StrMid = Left(StrMid, Len(StrMid) - 1)
      End If
    Next
    j = CLng(Replace(StrTmp, StrMid, ""))
    StrTmp = ""
    For k = i To j
      StrTmp = StrTmp & StrPfx & StrMid & k & StrSfx & Chr(11)
    Next
    StrTmp = Replace(StrTmp, "\", "")
    .Text = Left(StrTmp, Len(StrTmp) - 1)
    .Collapse wdCollapseEnd
    .Find.Execute
  Loop
End With
Application.ScreenUpdating = True
End Sub
With the above code, there is no need for your data outside the table.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Need to repeat macro for multiple times Mail Merge Repeat Record a certain number of times stacey_e Mail Merge 7 07-07-2023 01:27 AM
Repeat macro until no more fields ChrisJ83 Word VBA 2 01-20-2016 04:55 AM
Need to repeat macro for multiple times Print Format - Repeat Text From a Cell on Multiple Pages ChristopherHughes Excel 1 12-07-2014 08:31 PM
Need to repeat macro for multiple times How to repeat multiple .jpg's over again in Custom Slide show pbyrescue PowerPoint 1 04-03-2014 12:40 PM
Repeat formula 5 times and repeat? Jenny345 Excel 4 06-14-2013 04:37 PM

Other Forums: Access Forums

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