View Single Post
 
Old 08-31-2021, 11:50 AM
p45cal's Avatar
p45cal p45cal is offline Windows 10 Office 2019
Expert
 
Join Date: Apr 2014
Posts: 871
p45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond repute
Default

Try:
Code:
Sub blah()
'Set rngToSort = Range("A2:A36")
'Set rngToSort = Selection
Set rngToSort = Range(Cells(2, "A"), Cells(Rows.Count, "A").End(xlUp))
rngToSort.Value = Application.SortBy(rngToSort, Evaluate("LEN(" & rngToSort.Address(external:=True) & ")"), -1)
End Sub
Set rngToSort any way you like - a few examples at the top of the macro. Apart from that it's a one-liner.
Reply With Quote