![]() |
|
#1
|
|||
|
|||
|
Hi Guys
I need to sort data in column A ranges A2:end of value based on their length using excel macro. I have attached my file to sort column A. Can anyone help out on this? I have used this function but i need to add this as macro: SORTBY(A2:A36,LEN(A2:A36),-1) thanks |
|
#2
|
||||
|
||||
|
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
|
|
#3
|
|||
|
|||
|
Thanks so much!
Works perfectly!! |
|
|
|
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 |
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 |
How to Sort Table Cells from Left to Right
|
tamaracklodge | Word Tables | 4 | 03-04-2013 04:00 AM |