B
Beepa
I often need to copy an itemized bill from the Web in order to sort it. I
copy and paste it into Word and it comes in as one huge paragraph. I want to
format it into paragraphs, then convert it to a table using the spaces
between each column to separate into cells. I've written the following macro
to format break each line of data into a separate line (paragraph), but I
need to make it loop. Can anyone tell me where and what code to insert to
make it loop until it reaches the end of my unformatted text (when there is
not another / or : to be found)? Here's what works manually, without a loop:
Sub Phonebill ()
Selection.Find.ClearFormatting
With Selection.Find
.Text = "/"
.Replacement.Text = "^p"
.Forward = True
.Wrap = wdFindAsk
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchKashida = False
.MatchDiacritics = False
.MatchAlefHamza = False
.MatchControl = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.MoveLeft Unit:=wdWord, Count:=3
Selection.TypeParagraph
Selection.Find.ClearFormatting
With Selection.Find
.Text = ":"
.Replacement.Text = "^p"
.Forward = True
.Wrap = wdFindStop
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchKashida = False
.MatchDiacritics = False
.MatchAlefHamza = False
.MatchControl = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.MoveRight Unit:=wdCharacter, Count:=1
End Sub
copy and paste it into Word and it comes in as one huge paragraph. I want to
format it into paragraphs, then convert it to a table using the spaces
between each column to separate into cells. I've written the following macro
to format break each line of data into a separate line (paragraph), but I
need to make it loop. Can anyone tell me where and what code to insert to
make it loop until it reaches the end of my unformatted text (when there is
not another / or : to be found)? Here's what works manually, without a loop:
Sub Phonebill ()
Selection.Find.ClearFormatting
With Selection.Find
.Text = "/"
.Replacement.Text = "^p"
.Forward = True
.Wrap = wdFindAsk
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchKashida = False
.MatchDiacritics = False
.MatchAlefHamza = False
.MatchControl = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.MoveLeft Unit:=wdWord, Count:=3
Selection.TypeParagraph
Selection.Find.ClearFormatting
With Selection.Find
.Text = ":"
.Replacement.Text = "^p"
.Forward = True
.Wrap = wdFindStop
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchKashida = False
.MatchDiacritics = False
.MatchAlefHamza = False
.MatchControl = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.MoveRight Unit:=wdCharacter, Count:=1
End Sub