EXCEL TOOLS
Excel Add-ins ที่พัฒนาโดยคุณสันติพงศ์ ณสุย (MVP Excel 2010-2020) ด้วยภาษา C# เพื่อแก้ไขปัญหาไฟล์ใหญ่ คำนวณนาน ทำงานช้า จัดการข้อมูลต่าง ๆ ที่ทำงานประจำวันได้อย่างสะดวกรวดเร็ว สนใจคลิกไปดูได้ที่นี่ครับ => Excel Tools
Excel Add-ins ที่พัฒนาโดยคุณสันติพงศ์ ณสุย (MVP Excel 2010-2020) ด้วยภาษา C# เพื่อแก้ไขปัญหาไฟล์ใหญ่ คำนวณนาน ทำงานช้า จัดการข้อมูลต่าง ๆ ที่ทำงานประจำวันได้อย่างสะดวกรวดเร็ว สนใจคลิกไปดูได้ที่นี่ครับ => Excel Tools
[code]
และปิดด้วย [/code]
ตัวอย่างเช่น [code]dim r as range[/code]
เพื่อให้แตกต่างจากข้อความทั่วไป สะดวกในการอ่านและทดสอบ (คลิกเพื่อดูตัวอย่าง)Code: Select all
Dim Result(10) As Double
Dim Ave As Double
Dim x, y, z, Sum As Double
'''' *** Average *** ''"
Result(1) = CDbl(txtBox1.Value)
Result(2) = CDbl(txtBox2.Value)
Result(3) = CDbl(txtBox3.Value)
Result(4) = CDbl(txtBox4.Value)
Result(5) = CDbl(txtBox5.Value)
Result(6) = CDbl(txtBox6.Value)
Result(7) = CDbl(txtBox7.Value)
Result(8) = CDbl(txtBox8.Value)
Result(9) = CDbl(txtBox9.Value)
Result(10) = CDbl(txtBox10.Value)
Ave = Application.WorksheetFunction.Average(Result)
txtStandard.Value = Ave
txtStandard.Value = Format(txtStandard, "##,##0.000")
if txtBox3.Value = "" then exit sub
Code: Select all
if txtBox3.Value = "" then
msgbox "txtBox3 can't be blank"
exit sub
end if
Code: Select all
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
Code: Select all
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