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 thisSorry, I forgot to mention that my data are scattered and I want to paste them in one column
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
Try this...Thanks everyone and I apologize for incomplete definition of my problem. This image should make things clearer </SPAN>
Here's a non-array formula option.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))
Yes, you can put the formula in cell V22 anywhere you want.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?
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
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?