- ©«¤l
- 5923
- ¥DÃD
- 13
- ºëµØ
- 1
- ¿n¤À
- 5986
- ÂI¦W
- 0
- §@·~¨t²Î
- win10
- ³nÅ骩¥»
- Office 2010
- ¾\ŪÅv
- 150
- ©Ê§O
- ¨k
- ¨Ó¦Û
- ¥xÆW°ò¶©
- µù¥U®É¶¡
- 2010-5-1
- ³Ì«áµn¿ý
- 2022-1-23
|
¦^´_ 8# yeh6712 - Option Explicit
- Sub Ex1()
- Dim i As Integer, J As Integer, A As Integer, AJ(), AA()
- UsedRange.Offset(1, 2) = ""
- ReDim AJ(1 To [B1].End(xlDown).Row - 1)
- ReDim AA(1 To [A1].End(xlDown).Row - 1)
- '**** ¤H¤H¦³¼ú(¤@¶µ)
- Do Until i + 1 = [A1].End(xlDown).Row '¤Hû
- J = Int((([B1].End(xlDown).Row - 1) * Rnd) + 1) '¶Ã¼Æ¤¶©ó 1 - ¼ú¶µ¼Æ¶q ¤§¶¡
- If AJ(J) = "" Then
- A = Int((([A1].End(xlDown).Row - 1) * Rnd) + 1) '¶Ã¼Æ¤¶©ó 1 - ¤Hû¼Æ¶q ¤§¶¡
- If AA(A) = "" Then
- AJ(J) = J
- AA(A) = J
- Range("C" & J + 1) = Range("A" & A + 1) '¼ú«~±o¼ú¤Hû
- i = i + 1
- End If
- End If
- Loop
- '**** ©â¥X³Ñ¾lªº¼ú¶µ
- For J = 1 To UBound(AJ)
- If AJ(J) = "" Then '¥¼©â¥Xªº¼ú¶µ
- Do
- A = Int((([A1].End(xlDown).Row - 1) * Rnd) + 1) '¶Ã¼Æ¤¶©ó 1 - ¤Hû¼Æ¶q ¤§¶¡
- If InStr(AA(A), ",") = 0 Then 'InStr(AA(A), ",") = 0;±Æ°£±o2Ó¥H¤W¼ú¶µ
- AA(A) = AA(A) & "," & J
- Range("C" & J + 1) = Range("A" & A + 1)
- Exit Do
- End If
- Loop
- End If
- Next
- [D2].Resize(UBound(AA)) = Application.WorksheetFunction.Transpose(AA) '¤Hûªº±o¼ú¼ú«~
- End Sub
½Æ»s¥N½X |
|