- ©«¤l
- 561
- ¥DÃD
- 160
- ºëµØ
- 0
- ¿n¤À
- 725
- ÂI¦W
- 0
- §@·~¨t²Î
- WINDOWS
- ³nÅ骩¥»
- xp
- ¾\ŪÅv
- 50
- ©Ê§O
- ¨k
- ¨Ó¦Û
- ®ç¶é
- µù¥U®É¶¡
- 2014-9-10
- ³Ì«áµn¿ý
- 2024-8-7
|
¦p¤U¤Þ¥Î«e½ú§@«~
Sub ¶Ã¼Æ¤£«½Æ()
Const rnd_start = 11 '¶Ã¼Æ±Ò©lÈ
Const rnd_end = 20 '¶Ã¼Æµ²§ôÈ
Const cell_start = 1 'n²£¥Í¶Ã¼ÆªºÀx¦s®æ±Ò©l¦C
Const cell_end = 5 'n²£¥Í¶Ã¼ÆªºÀx¦s®æµ²§ô¦C
Const Mycol = "A" 'n²£¥Í¶Ã¼ÆªºÀx¦s®æÄæ
Dim Buf_rnd As Long '¥Î¨Ó¼È®É¦s©ñ¶Ã¼ÆÈ¡Aµ¥¤ñ¹ï¨S¦³«½Æ«á¤~¦s¤JÀx¦s®æ
Dim i As Long
Dim j As Long
If rnd_end - rnd_start < cell_end - cell_start Then
MsgBox "²£¥Í¤£«½Æªº¶Ã¼Æ°Ï¶¡¤£¥i¥H¤ñn²£¥Í¶Ã¼ÆªºÀx¦s®æªº¼ÆÈÁÙn¤Ö¡C"
Exit Sub
End If
'²£¥Í¶Ã¼Æ
For i = cell_start To cell_end
1 Buf_rnd = Int(Rnd() * (rnd_end - rnd_start + 1)) + rnd_start
'¦pªG¤£¬O²Ä1ÓÀx¦s®æ´Nn©¹«e¤ñ¹ï¡C
If i > cell_start Then
For j = cell_start To i - 1
'¦pªG«½Æ¤F´N¸õ¨ì 1 «·s²£¥Í¶Ã¼Æ¡C
If Buf_rnd = Range(Mycol & j).Value Then GoTo 1
Next j
End If
Range(Mycol & i).Value = Buf_rnd
Next i
End Sub |
|