Function dia2()
Dim d As Single
Dim i As Single
d = Sheet2.[c2].Value
Select Case True
Case d >= 0 And d < 3
i = 6
Case d >= 3 And d < 6
i = 7
Case d >= 6 And d < 10
i = 8
Case d >= 10 And d < 18
i = 9
Case d >= 18 And d < 30
i = 10
Case d >= 30 And d < 50
i = 11
Case d >= 50 And d < 80
i = 12
Case Else
MsgBox "直徑超80,不計算"
End Select
j = i
''''''''''''''''''''''''''''''''''''''''''
Dim it(1 To 7)
Dim itt(1 To 7) '減去公差值的數(shù)組
Dim k As Integer
Dim kk As Integer '下標(biāo)
Dim m As Integer
Dim c As Single
Dim t As Single
Dim z As Single
m = 2
For k = 1 To 7
it(k) = Sheet1.Cells(j, k + m).Value
itt(k) = Abs(it(k) - 1000 * Sheet2.[g2].Value)
m = m + 2
Next k
c = Application.Min(itt)
kk = Application.Match(c, itt, 0)
t = Sheet1.Cells(i, 3 * kk + 1)
z = Sheet1.Cells(i, 3 * kk + 2)
''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sheet2.Cells(4, 3) = Round(t, 3)
Sheet2.Cells(5, 3) = Round(z, 3)
End Function
Private Sub CommandButton1_Click()
dia2
End Sub
Private Sub CommandButton2_Click()
End
End Sub