- ©«¤l
- 1018
- ¥DÃD
- 15
- ºëµØ
- 0
- ¿n¤À
- 1058
- ÂI¦W
- 0
- §@·~¨t²Î
- win7 32bit
- ³nÅ骩¥»
- Office 2016 64-bit
- ¾\ŪÅv
- 50
- ©Ê§O
- ¨k
- ¨Ó¦Û
- ®ç¶é
- µù¥U®É¶¡
- 2012-5-9
- ³Ì«áµn¿ý
- 2022-9-28
|
¥»©«³Ì«á¥Ñ stillfish00 ©ó 2014-1-13 20:36 ½s¿è
¦^´_ 1# yeh6712
¥ÎVBA®É¡A¦]¬°Rank²Ä¤G°Ñ¼Æ¦n¹³¤£¤ä´©array§Î¦¡¡A©Ò¥H¹³¤U±³o¼ËÅo¶Û¤F¤@ÂI
ª««~Äæ¤]¥i¥H¤£¥Î¼Æ¦r- Sub TEST()
- Dim rngTest As Range, rngB As Range, ar, i
-
- With ActiveSheet
- Set rngTest = .Range(.[A2], .Cells(.Rows.Count, "A").End(xlUp)).Offset(, 2)
- Set rngB = .Range(.[B2], .Cells(.Rows.Count, "B").End(xlUp))
-
- Randomize Now
- For i = 1 To rngTest.Count
- rngTest(i).Value = Rnd
- Next
-
- ReDim ar(1 To rngTest.Count)
- For i = LBound(ar) To UBound(ar)
- ar(i) = Application.WorksheetFunction.Rank(rngTest(i).Value, rngTest)
- ar(i) = IIf(ar(i) > rngB.Count, "", rngB(ar(i)))
- Next
-
- rngTest.Value = Application.Transpose(ar)
- End With
- End Sub
½Æ»s¥N½X |
|