Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #2  
Old 08-31-2021, 11:50 AM
p45cal's Avatar
p45cal p45cal is offline Need to sort based on the length of cells Windows 10 Need to sort based on the length of cells Office 2019
Expert
 
Join Date: Apr 2014
Posts: 956
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
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Sort pages based on header comphi Word VBA 0 09-22-2018 11:14 PM
Conditional formating all cells in an array based on adjacent cells deejay Excel 6 12-20-2016 12:00 PM
Need to sort based on the length of cells How to add new pages based on the length of a TOC? gn4619 Word VBA 2 04-28-2015 06:37 AM
Is it possible to sort cells in shades of colors? Kreol2013 Excel Programming 9 02-09-2014 02:38 PM
Need to sort based on the length of cells How to Sort Table Cells from Left to Right tamaracklodge Word Tables 4 03-04-2013 04:00 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 12:35 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft