Sub jec()
sp = Range("A2", Range("A" & Rows.Count).End(xlUp))
sp2 = Application.RandArray(UBound(sp), 1)
ReDim ar(1 To UBound(sp), 1 To 2)
For j = 1 To (UBound(sp) * 0.1)
ar(j, 1) = sp(Application.Match(Application.Large(sp2, j), sp2, 0), 1)
ar(j, 2) = j
Next
Range("A2", Range("A" & Rows.Count).End(xlUp)).Offset(, 1).Resize(10) = ar
End Sub
thank you so much. My VBA is truly awful henxe the reason I stick to excelVBA solution as well:
VBA Code:Sub jec() sp = Range("A2", Range("A" & Rows.Count).End(xlUp)) sp2 = Application.RandArray(UBound(sp), 1) ReDim ar(1 To UBound(sp), 1 To 2) For j = 1 To (UBound(sp) * 0.1) ar(j, 1) = sp(Application.Match(Application.Large(sp2, j), sp2, 0), 1) ar(j, 2) = j Next Range("A2", Range("A" & Rows.Count).End(xlUp)).Offset(, 1).Resize(10) = ar End Sub
thank you much for thisBut, if you use the formula version, you should set your calculation settings to manual. Otherwise the formula is recalculating every time you make a change in your worksheet.