Filter list per Character From Smallest to Highest using code

bordetaning

New Member
Joined
Dec 23, 2013
Messages
12
Hi Guys,

Is there a way we can filter list based on the number of character in a cell from lowest to highest using code alone?

Sample Below
Sa1
Sample 23
Samepl
Samples

Output
Sa1
Samepl
Samples
Sample 23


Thanks,
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
1) Say your list starts at A1. Enter in B1 =len(A1) and copy down.
2) Use col C1 to C4 to number each item (1-4)
3) Enter in D1 =small(B:B,C1) and copy down
4) Enter in E1 =INDEX(A:A,MATCH(D1,B:B,0)) and copy down
(y)
 
Upvote 0
1) Say your list starts at A1. Enter in B1 =len(A1) and copy down.
2) Use col C1 to C4 to number each item (1-4)
3) Enter in D1 =small(B:B,C1) and copy down
4) Enter in E1 =INDEX(A:A,MATCH(D1,B:B,0)) and copy down
(y)
I would use your first step, but then I would select Columns A and B and sort on Column B, then clear Column B.
 
Upvote 0
Hi Guys,

I appreciate you taking time in viewing and answering my post. I've tried the the formula and it works but the problem I noticed now is that it won't filter all entries that has the same number of charcter.

Example
Sample1
Sample2
Sample3

the output will only filter the first entry
Sample1
Sample1
Sample1

Is there any way we can filter all entries that has the same number of characters using formula and some tricks alone?

Thanks so much guys :)
 
Upvote 0
I appreciate you taking time in viewing and answering my post. I've tried the the formula and it works but the problem I noticed now is that it won't filter all entries that has the same number of charcter.
Did you try the variation on Bill's method that I proposed in Message #3?
 
Upvote 0
Oops... add change in red text:

1) Say your list starts at A1. Enter in B1 =len(A1)
+row()/10000 and copy down. (This adds a fraction of the row # so as to differentiate items. Make it 100000 if 10000 isn't enough)
2) Use col C1 to C4 to number each item (1-4)
3) Enter in D1 =small(B:B,C1) and copy down
4) Enter in E1 =INDEX(A:A,MATCH(D1,B:B,0)) and copy down

Now... I'm guessing your next question will be... how to alphabetize the list after it is sorted by length?

Stick these in row 1 and copy down as needed

F1 =LEN(E1)/10000&E1
G1 =COUNTIF(F:F,"<="&F1)+ROW()/10000
H1 =SMALL(G:G,I1)
I1 = row()
J1 =INDEX(E:E,MATCH(H1,G:G,0))


Or you could use Rick's method and sort 1st on length of item and 2nd on the list of items.
(y)
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,813
Messages
6,121,706
Members
449,048
Latest member
81jamesacct

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top