snasui.com ยินดีต้อนรับ ยินดีต้อนรับสู่กระดานถามตอบ Excel and VBA และอื่น ๆ ที่เป็นมิตรกับทุกท่าน มีไฟล์แนบมหาศาล ช่วยให้ท่านค้นหาและติดตามศึกษาได้โดยง่าย สมาชิกท่านใดที่ยังไม่ได้ระบุ Version ของ Excel ที่ใช้งานจริง สามารถทำตาม Link นี้เพื่อจะได้รับคำตอบที่ตรงกับ Version ของท่านครับ ระบุ Version ของ Excel
Private Sub txtPiece_Change()
Dim Result(10) As Double
Dim Ave As Double
Dim x, y, z, Sum As Double
''' *** Average *** ''"
If txtBox1.Text = "" Then GoTo Ave
Result(1) = CDbl(txtBox1.Value)
If txtBox2.Text = "" Then GoTo Ave
Result(2) = CDbl(txtBox2.Value)
If txtBox3.Text = "" Then GoTo Ave
Result(3) = CDbl(txtBox3.Value)
If txtBox4.Text = "" Then GoTo Ave
Result(4) = CDbl(txtBox4.Value)
If txtBox5.Text = "" Then GoTo Ave
Result(5) = CDbl(txtBox5.Value)
If txtBox6.Text = "" Then GoTo Ave
Result(6) = CDbl(txtBox6.Value)
If txtBox7.Text = "" Then GoTo Ave
Result(7) = CDbl(txtBox7.Value)
If txtBox8.Text = "" Then GoTo Ave
Result(8) = CDbl(txtBox8.Value)
If txtBox9.Text = "" Then GoTo Ave
Result(9) = CDbl(txtBox9.Value)
If txtBox10.Text = "" Then GoTo Ave
Result(10) = CDbl(txtBox10.Value)
Ave:
Ave = Application.WorksheetFunction.Average(Result)
txtStandard.Value = Ave
txtStandard.Value = Format(txtStandard, "##,##0.000")
'"" *** หา % *** ""'
If (txtPiece.Value < 0.0598) Then
txtPercent.Value = "0.2"
ElseIf (txtPiece.Value > 0.0999) Then
txtPercent.Value = "0.5"
ElseIf (txtPiece.Value <> "0.0599 - 0.0998") Then
txtPercent.Value = "0.3"
End If
'''' *** Sum Lower *** ''"
x = Val(txtStandard.Value)
y = Val(txtPercent.Value)
z = Val(txtPiece.Value)
Sum = x - (y * z)
txtLower.Value = Format(Sum, "##,##0.000")
'''' *** Sum Upper *** ''"
x = Val(txtStandard.Value)
y = Val(txtPercent.Value)
z = Val(txtPiece.Value)
Sum = x + (y * z)
txtUpper.Value = Format(Sum, "##,##0.000")
End Sub
You do not have the required permissions to view the files attached to this post.
Private Sub txtPiece_Change()
Dim Result(10) As Variant
Dim Ave As Double
Dim x, y, z, Sum As Double
''' *** Average *** ''"
If txtBox1.Text = "" Then GoTo Ave
Result(1) = CDbl(txtBox1.Value)
If txtBox2.Text = "" Then GoTo Ave
Result(2) = CDbl(txtBox2.Value)
If txtBox3.Text = "" Then GoTo Ave
Result(3) = CDbl(txtBox3.Value)
If txtBox4.Text = "" Then GoTo Ave
Result(4) = CDbl(txtBox4.Value)
If txtBox5.Text = "" Then GoTo Ave
Result(5) = CDbl(txtBox5.Value)
If txtBox6.Text = "" Then GoTo Ave
Result(6) = CDbl(txtBox6.Value)
If txtBox7.Text = "" Then GoTo Ave
Result(7) = CDbl(txtBox7.Value)
If txtBox8.Text = "" Then GoTo Ave
Result(8) = CDbl(txtBox8.Value)
If txtBox9.Text = "" Then GoTo Ave
Result(9) = CDbl(txtBox9.Value)
If txtBox10.Text = "" Then GoTo Ave
Result(10) = CDbl(txtBox10.Value)
Ave:
Ave = Application.WorksheetFunction.Average(Result)
txtStandard.Value = Ave
txtStandard.Value = Format(txtStandard, "##,##0.000")
'"" *** หา % *** ""'
If (txtPiece.Value < 0.0598) Then
txtPercent.Value = "0.2"
ElseIf (txtPiece.Value > 0.0999) Then
txtPercent.Value = "0.5"
ElseIf (txtPiece.Value <> "0.0599 - 0.0998") Then
txtPercent.Value = "0.3"
End If
'''' *** Sum Lower *** ''"
x = Val(txtStandard.Value)
y = Val(txtPercent.Value)
z = Val(txtPiece.Value)
Sum = x - (y * z)
txtLower.Value = Format(Sum, "##,##0.000")
'''' *** Sum Upper *** ''"
x = Val(txtStandard.Value)
y = Val(txtPercent.Value)
z = Val(txtPiece.Value)
Sum = x + (y * z)
txtUpper.Value = Format(Sum, "##,##0.000")
End Sub