Word macro to convert from a vertical list to a horizontal list (separated by comma)

Let’s say you have a list:

word1

word2

word3

You need to convert this into:

word1, word2, word3

Sure, it’s not hard to do it just one time. But what happens if you need this on a regular basis?

I’ve created a Microsoft Word macro that helps with that.

You have an empty document looking like this:

word1

word2

word3

It will convert this into:

word1, word2, word3

In the end, after you run it, it cuts the data, all you need is to paste.

Sub Din_Enter_in_virgula_Din_Lista_Verticala_in_Lista_Orizontala()

‘ Macro1 Macro


Selection.WholeStory
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = “^p”
.Replacement.Text = “, ”
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll

Selection.WholeStory
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = “, ^p”
.Replacement.Text = “”
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
Selection.Cut

End Sub

You can add a macro to quick launch in Word, and this is how to install macros in Word.

michael szpakowski - list
michael szpakowski – list, https://flic.kr/p/2j9xxV8
Partajează pe WhatsApp

Lasă un comentariu

Acest sit folosește Akismet pentru a reduce spamul. Află cum sunt procesate datele comentariilor tale.