Excel VBA質問スレ Part8
■ このスレッドは過去ログ倉庫に格納されています
0693デフォルトの名無しさん
2008/10/29(水) 02:45:55具体例:
(1)乱数で10個のデータを生成し,列方向に保存
(2)保存したデータから平均を計算し, 2つ下のセルに出力
(3)上記(1)から(2) を n回繰り返す(とりあえずn=3).
上記(2)がうまく計算できません(下から3行目のコード).
---------------
Sub dice_siml01()
Cells.Clear
Dim i As Integer
Dim j As Integer
Dim n As Integer
Dim nobs As Integer
Cells(1, 1) = "試行回数"
n = 3
nobs = 10
For j = 1 To n
For i = 1 To nobs
Cells(i + 1, j + 1).Formula = "=randbetween(1,6)"
Next
Cells(nobs + 3, j + 1).Formula = "=Average(Range(Cells(2, j+1), Cells(2+nobs-1, j+1)))" Next
End Sub
---------------
【注】
randbetween(1,6) エラーの場合 rand()で置き換えてお願いします.
■ このスレッドは過去ログ倉庫に格納されています