|
エクセルVBA超初心者です。
ユーザーフォムにテキトボックスを20個配置し、下記の標準偏差求める構文をを作りました。
20個のデータを入力すれば問題ないのですが、データは20個以下の場合があり
テキトボックスを空白のまま実行すると、実行時エラー13 型が一致しませんのエラー
が発生します。空白のテキトボックスに0を入力すればよいのですがそれがめんどうで!
なにかよい解決法があれば宜しくご教授ください。
Option Explicit
Private Sub CommandButton1_Click()
Dim r As Integer, s As Integer
r = ActiveCell.Row
s = ActiveCell.Column
Dim t1 As Double, t2 As Single, t3 As Single, t4 As Single, t5 As Single
Dim t6 As Single, t7 As Single, t8 As Single, t9 As Single, t10 As Single
Dim t11 As Single, t12 As Single, t13 As Single, t14 As Single, t15 As Single
Dim t16 As Single, t17 As Single, t18 As Single, t19 As Single, t20 As Single
t1 = TextBox2
t2 = TextBox5
t3 = TextBox8
t4 = TextBox9
t5 = TextBox10
t6 = TextBox11
t7 = TextBox12
t8 = TextBox13
t9 = TextBox14
t10 = TextBox15
t11 = TextBox16
t12 = TextBox17
t13 = TextBox18
t14 = TextBox21
t15 = TextBox24
t16 = TextBox27
t17 = TextBox30
t18 = TextBox33
t19 = TextBox36
t20 = TextBox39
Cells(r, s) = Application.WorksheetFunction.StDev(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, _
t11, t12, t13, t14, t15, t16, t17, t18, t19, t20)
End Sub
|
|