演習11 のユーザーフォーム コード
------ [UserForm1] -------
Private Sub Average_Click()
Dim A As Single
Dim R As String
With Worksheets("Sheet1")
A = Application.WorksheetFunction.Average(Range("B1:B10"))
MsgBox "平均は " & A
For J = 4 To 5
.Cells(2, J).Interior.Color = QBColor(13)
Next J
R = Space(8): RSet R = "平均"
.Cells(2, 4).Value = R
.Cells(2, 5).Value = A
.Range("A1").Activate
End With
End Sub
Private Sub Clear_Click()
With Worksheets("Sheet1")
.Range("D1:E3").Clear
End With
End Sub
Private Sub Closed_Click()
End
End Sub
Private Sub Stdev_Click()
Dim D As Single
Dim R As String
With Worksheets("Sheet1")
D = Application.WorksheetFunction.Stdev(Range("B1:B10"))
MsgBox "標準偏差は " & D
For J = 4 To 5
.Cells(3, J).Interior.Color = QBColor(11)
Next J
R = Space(4): RSet R = "標準偏差"
.Cells(3, 4).Value = R
.Cells(3, 5).Value = D
.Range("A1").Activate
End With
End Sub
Private Sub Sum_Click()
Dim S As Integer
Dim R As String
With Worksheets("Sheet1")
S = Application.WorksheetFunction.Sum(Range("B1:B10"))
MsgBox "合計は " & S
For J = 4 To 5
.Cells(1, J).Interior.Color = QBColor(14)
Next J
R = Space(8): RSet R = "合計"
.Cells(1, 4).Value = R
.Cells(1, 5).Value = S
.Range("A1").Activate
End With
End Sub
back top