Does anyone have a clue for a macro that can sort a list of words
according to how many letters there are in the words.
Example: I'd like the list:

bear
do
horse
a
are

to end up like:

a
do
are
bear
horse


thanks to anyone who can help!
--
per-erik

Re: Sort according to word length by Doug

Doug
Wed Oct 19 12:57:37 CDT 2005

The following will do it provided that each word is in a separate paragraph:

Dim i As Long
With ActiveDocument
.Range.ConvertToTable Separator:=vbCr, AutoFit:=True
.Tables(1).Columns.Add BeforeColumn:=.Tables(1).Columns(1)
For i = 1 To .Tables(1).Rows.Count
.Tables(1).Cell(i, 1).Range = Len(.Tables(1).Cell(i, 2).Range.Text)
Next i
.Tables(1).Sort
.Tables(1).Columns(1).Delete
.Tables(1).ConvertToText
End With


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"perskram attttt gmail dotttt com" <"perskram attttt gmail dotttt com">
wrote in message news:43567032$1@news.broadpark.no...
> Does anyone have a clue for a macro that can sort a list of words
> according to how many letters there are in the words.
> Example: I'd like the list:
>
> bear
> do
> horse
> a
> are
>
> to end up like:
>
> a
> do
> are
> bear
> horse
>
>
> thanks to anyone who can help!
> --
> per-erik



Re: Sort according to word length by Jezebel

Jezebel
Wed Oct 19 16:28:49 CDT 2005

Simplest is to paste the list into Excel. Use the Len() function to get the
lengths, then sort on that.




"perskram attttt gmail dotttt com" <"perskram attttt gmail dotttt com">
wrote in message news:43567032$1@news.broadpark.no...
> Does anyone have a clue for a macro that can sort a list of words
> according to how many letters there are in the words.
> Example: I'd like the list:
>
> bear
> do
> horse
> a
> are
>
> to end up like:
>
> a
> do
> are
> bear
> horse
>
>
> thanks to anyone who can help!
> --
> per-erik



Re: Sort according to word length by Doug

Doug
Wed Oct 19 23:06:18 CDT 2005

The following will do it provided that each word is in a separate paragraph:

Dim i As Long
With ActiveDocument
.Range.ConvertToTable Separator:=vbCr, AutoFit:=True
.Tables(1).Columns.Add BeforeColumn:=.Tables(1).Columns(1)
For i = 1 To .Tables(1).Rows.Count
.Tables(1).Cell(i, 1).Range = Len(.Tables(1).Cell(i, 2).Range.Text)
Next i
.Tables(1).Sort
.Tables(1).Columns(1).Delete
.Tables(1).ConvertToText
End With


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"perskram attttt gmail dotttt com" <"perskram attttt gmail dotttt com">
wrote in message news:43567032$1@news.broadpark.no...
> Does anyone have a clue for a macro that can sort a list of words
> according to how many letters there are in the words.
> Example: I'd like the list:
>
> bear
> do
> horse
> a
> are
>
> to end up like:
>
> a
> do
> are
> bear
> horse
>
>
> thanks to anyone who can help!
> --
> per-erik



Re: Sort according to word length by perskram

perskram
Thu Oct 20 04:12:15 CDT 2005

Doug Robbins - Word MVP wrote:
> The following will do it provided that each word is in a separate paragraph:
>
> Dim i As Long
> With ActiveDocument
> .Range.ConvertToTable Separator:=vbCr, AutoFit:=True
> .Tables(1).Columns.Add BeforeColumn:=.Tables(1).Columns(1)
> For i = 1 To .Tables(1).Rows.Count
> .Tables(1).Cell(i, 1).Range = Len(.Tables(1).Cell(i, 2).Range.Text)
> Next i
> .Tables(1).Sort
> .Tables(1).Columns(1).Delete
> .Tables(1).ConvertToText
> End With

It worked great! Thanks!

p-e