Private Sub CommandButton1_Click()
''MsgBox "ok"
Dim j1, j1k, sum1, max1, kol1
Dim ws1 As Worksheet
Set ws1 = Excel.Worksheets("лист1")
sum1 = 0
max1 = 0
kol1 = 0
j1 = 1
j1k = 100
Do While j1 < j1k
j1 = j1 + 1
If LCase(ws1.Cells(j1, 1)) = LCase(Me.TextBox2) Then
sum1 = sum1 + ws1.Cells(j1, 3)
kol1 = kol1 + 1
If ws1.Cells(j1, 3) > max1 Then
max1 = ws1.Cells(j1, 3)
End If
End If
Loop
Me.TextBox3 = sum1
If kol1 = 0 Then
MsgBox Me.TextBox2 & " не найден"
Else
Me.TextBox5 = sum1 / kol1
End If
Me.TextBox4 = max1
End Sub
''MsgBox "ok"
Dim j1, j1k, sum1, max1, kol1
Dim ws1 As Worksheet
Set ws1 = Excel.Worksheets("лист1")
sum1 = 0
max1 = 0
kol1 = 0
j1 = 1
j1k = 100
Do While j1 < j1k
j1 = j1 + 1
If LCase(ws1.Cells(j1, 1)) = LCase(Me.TextBox2) Then
sum1 = sum1 + ws1.Cells(j1, 3)
kol1 = kol1 + 1
If ws1.Cells(j1, 3) > max1 Then
max1 = ws1.Cells(j1, 3)
End If
End If
Loop
Me.TextBox3 = sum1
If kol1 = 0 Then
MsgBox Me.TextBox2 & " не найден"
Else
Me.TextBox5 = sum1 / kol1
End If
Me.TextBox4 = max1
End Sub