µ¹·Q¾Ç±o¤H °Ñ¦Ò:D
Sub ³Ì²³æªk___________________()
'²Õ¼Æ¹L¤j®É, ¹Bºâ·|·¥«×¯Ó®É
¥§¡È = [A2]
¤W = [B2]
¤U = [C2]
²Õ¼Æ = [D2]
Randomize '«¸m¶Ã¼Æ
'----------------------------Do °j°é------------------------------------
Do
Value_Sum = 0
For w = 1 To (²Õ¼Æ - 1) 'for °j°é(°²¦p ²Õ¼Æ21 ¥u·|¶]20¦¸)
For w = 1 To (²Õ¼Æ - 1)
Value = Rnd * (¤W - ¤U) + ¤U
Value_Sum = Value_Sum + Value
Range("G" & w) = Value
Next
Value = ¥§¡È * ²Õ¼Æ - Value_Sum
If Value < ¤U Then
´ÝÈ = Value - ¤U
Value = ¤U
End If
If Value > ¤W Then
´ÝÈ = Value - ¤W
Value = ¤W
End If
Range("G" & w) = Value
If ´ÝÈ = 0 Then Exit Sub
Do
For w = 1 To ²Õ¼Æ
value_try = Range("G" & w) + (´ÝÈ / ²Õ¼Æ)
If value_try >= ¤U And value_try <= ¤W Then
Range("G" & w) = value_try
alls = alls + 1
If alls >= ²Õ¼Æ Then Exit Do
End If
Next
Loop