View Single Post
 
Old 08-18-2020, 06:01 PM
Guessed's Avatar
Guessed Guessed is online now Windows 10 Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 4,177
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

If you don't think it is important enough to provide realistic content and show the hidden formatting then I will just give you a macro that works with the content we assume you have provided.

Try this on a copy of your example document. If it works, try it on a copy of your real document.
Code:
Sub SortParasBySize()
  Dim aRng As Range, aTable As Table, aRow As Row

  ActiveDocument.Range.ConvertToTable Separator:=wdSeparateByParagraphs, NumColumns:=1
  Set aTable = ActiveDocument.Tables(1)
  aTable.Columns.Add BeforeColumn:=aTable.Columns(1)
  For Each aRow In aTable.Rows
    aRow.Cells(1).Range.Text = Len(aRow.Cells(2).Range.Text)
  Next aRow
  aTable.Rows.Add BeforeRow:=aTable.Rows(1)
  aTable.SortDescending
  aTable.Columns(1).Delete
  aTable.Rows(1).Delete
  aTable.ConvertToText
End Sub
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote