From smallest to largest without repeating

vacho

New Member
Joined
Dec 13, 2011
Messages
18
Hello,

I have data consisting of 20 numbers from 1 to 63. Within 20 some numbers can appear twice or even more. I want excel to sort this numbers in smallest to largest format ignoring repeating numbers.

Thank you
 
Slightly shorter from post #10

Excel Workbook
AB
277
3598
43812
51215
63627
72929
83432
91534
104036
115838
121240
13849
143857
153258
165759
177
1836
1915
2027
2149
Sheet1
 
Last edited:
Upvote 0

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
Sorry, I forgot to mention that my data are scattered and I want to paste them in one column
try this macro. it assumes your data are scattered down column A, if otherwise post back details. also assumes your data are integers, you didn't explicitly specify this
Code:
Sub sjsj()
Dim a as Range, b(63) As Boolean, c As Variant, d As Long
Set a = Intersect(ActiveSheet.UsedRange, Range("A:A"))
For Each c In a
    If Len(c) > 0 Then b(c) = True
Next
a.ClearContents
For c = 1 To 63
    If b(c) Then d = d + 1: a(d) = c
Next c
End Sub
 
Last edited:
Upvote 0
Thanks everyone and I apologize for incomplete definition of my problem. This image should make things clearer </SPAN>

excelsorting.jpg
 
Upvote 0
Thanks everyone and I apologize for incomplete definition of my problem. This image should make things clearer </SPAN>

excelsorting.jpg
Try this...

Enter this formula in V22. This will return the count of unique numbers in the ranges of interest.

=SUM(--(FREQUENCY((D22:H22,D29:H29,D36:H36,D43:H43),(D22:H22,D29:H29,D36:H36,D43:H44))>0))

Enter this formula in V24:

=MIN(D22:H22,D29:H29,D36:H36,D43:H43)

Enter this array formula** in V25:

=IF(ROWS(V$24:V25)>V$22,"",MIN(IF(MOD(ROW(D$22:H$43)-ROW(D$22),7)=0,IF(D$22:H$43>V24,D$22:H$43))))

** array formulas need to be entered using the key
combination of CTRL,SHIFT,ENTER (not just ENTER).
Hold down both the CTRL key and the SHIFT key
then hit ENTER.

Copy down until you get blanks.
 
Last edited:
Upvote 0
Try this...

Enter this formula in V22. This will return the count of unique numbers in the ranges of interest.

=SUM(--(FREQUENCY((D22:H22,D29:H29,D36:H36,D43:H43),(D22:H22,D29:H29,D36:H36,D43:H44))>0))

Enter this formula in V24:

=MIN(D22:H22,D29:H29,D36:H36,D43:H43)

Enter this array formula** in V25:

=IF(ROWS(V$24:V25)>V$22,"",MIN(IF(MOD(ROW(D$22:H$43)-ROW(D$22),7)=0,IF(D$22:H$43>V24,D$22:H$43))))

** array formulas need to be entered using the key
combination of CTRL,SHIFT,ENTER (not just ENTER).
Hold down both the CTRL key and the SHIFT key
then hit ENTER.

Copy down until you get blanks.
Here's a non-array formula option.

Entered in V25 and copied down until you get blanks:

=IF(ROWS(V$24:V25)>V$22,"",SMALL((D$22:H$22,D$29:H$29,D$36:H$36,D$43:H$43),FREQUENCY((D$22:H$22,D$29:H$29,D$36:H$36,D$43:H$43),V24)+1))
 
Upvote 0
Here's a non-array formula option.

Entered in V25 and copied down until you get blanks:

=IF(ROWS(V$24:V25)>V$22,"",SMALL((D$22:H$22,D$29:H$29,D$36:H$36,D$43:H$43),FREQUENCY((D$22:H$22,D$29:H$29,D$36:H$36,D$43:H$43),V24)+1))


this pormula does the trick until i get to the last value. for some reason 51 didn't display. Also can I move V22 value to another place in row24 for example?

Thanks anyway. You have already given enough info for me to continue
 
Last edited:
Upvote 0
this pormula does the trick until i get to the last value. for some reason 51 didn't display. Also can I move V22 value to another place in row24 for example?
Yes, you can put the formula in cell V22 anywhere you want.

Tell me exactly where you want that and where you want the other results to appear.

What version of Excel are you using?
 
Upvote 0
seems that you want a formula for this job.

however, just for interest, you may like to run this brief macro...easy to modify in whatever way
Code:
Sub sorted_norepeat()

Dim b(63) As Boolean, c As Long
Dim d As Long, e As Variant

For c = 22 To 43 Step 7
    For Each e In Cells(c, "d").Resize(, 5)
        b(e) = True
    Next
Next

For c = 1 To 63
    If b(c) Then d = d + 1: Cells(24, "v")(d) = c
Next c

End Sub
 
Upvote 0
Yes, you can put the formula in cell V22 anywhere you want.

Tell me exactly where you want that and where you want the other results to appear.

What version of Excel are you using?


Thanks, I moved the formula in an empty cell and also added -1 after ROWS(V$24:V25) in If statement as shown below and now it works just fine. I am using 2010 version.

=IF(ROWS(V$24:V25)-1>U$24,"",SMALL((D$22:H$22,D$29:H$29,D$36:H$36,D$43:H$43),FREQUENCY((D$22:H$22,D$29:H$29,D$36:H$36,D$43:H$43),V24)+1))

there is no way I could have thought of this solution, so thanks again
 
Upvote 0
Thank mirabeau, I will give it a try this evening. The reason why I don't want macros is, I have to activate it each time numbers change. Formulas change automatically
 
Upvote 0

Forum statistics

Threads
1,221,418
Messages
6,159,791
Members
451,589
Latest member
Harold14

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