Page 1 of 1

วิธีจัดทำรายงานสรุปใบเสร็จรับเงิน แบบ LINK สูตร

Posted: Sun Jan 11, 2015 4:59 pm
by annier_cute_1171986
ในแต่ละเดือน เรามีออกใบเสร็จรับเงินให้กับลูกค้าประมาณเดือนละ 200 ใบ ซึ่งเราต้อง COPY PASTE แต่ละใบเสร็จมาจัดทำ "รายงานสรุปใบเสร็จรับเงิน"

เอง ทำให้ใช้เวลาทำนานมาก ใน Excel มีสูตรไหนในการดึงรายละเอียดมาเป็นรายงานแบบทั้งเดือน กับ สรุปเป็นรายวันบ้างคะ แล้วต้องเขียนสูตรยังไงคะ

Re: วิธีจัดทำรายงานสรุปใบเสร็จรับเงิน แบบ LINK สูตร

Posted: Sun Jan 11, 2015 8:57 pm
by snasui
:D ควรอธิบายมาว่าข้อมูลต้นทางคือชีทใด ข้อมูลปลายทางคือชีทใด ตัวอย่างคำตอบที่ต้องการเป็นอย่างไร จะได้สะดวกในการทำความเข้าใจของเพื่อน ๆ ครับ

Re: วิธีจัดทำรายงานสรุปใบเสร็จรับเงิน แบบ LINK สูตร

Posted: Mon Jan 12, 2015 9:14 am
by annier_cute_1171986
ข้อมูลต้นทาง คือ Sheet 1 , 2 , 3 เป็นใบเสร็จรับเงินของทั้งเดือน ซึ่งแบบฟอร์มจะเหมือนกัน และ

ข้อมูลปลายทาง เป็น 1) สรุปรายงานใบเสร็จรับเงินทั้งเดือน มีรายละเอียดของทุกใบเสร็จรับเงิน

2) สรุปรายงานใบเสร็จรับเงินแยกเป็นวันๆ มียอดรวมที่เป็นจำนวนเงินในแต่ละวัน

Re: วิธีจัดทำรายงานสรุปใบเสร็จรับเงิน แบบ LINK สูตร

Posted: Mon Jan 12, 2015 8:59 pm
by snasui
:D ลักษณะของงานนี้ควรใช้ VBA เข้ามาจัดการ โดยทำแบบฟอร์มใบเสร็จขึ้นมาเพียงชีทเดียว มีปุ่มสำหรับการจัดเก็บข้อมูลลง Database

การทำรายงานก็จะนำข้อมูลจาก Database มาทำ ไม่ใช่นำมาจากชีทรายวันมาทำครับ

สำหรับการใช้ VBA จำเป็นต้องเขียนมาเองก่อนตามกฎการใช้บอร์ดข้อ 5 ด้านบน :roll: ติดตรงไหนค่อยถามกันต่อ

Re: วิธีจัดทำรายงานสรุปใบเสร็จรับเงิน แบบ LINK สูตร

Posted: Sat Dec 26, 2015 4:32 pm
by wichaipr
สรุปใบเสร็จรับเงิน

Re: วิธีจัดทำรายงานสรุปใบเสร็จรับเงิน แบบ LINK สูตร

Posted: Mon Dec 28, 2015 10:03 am
by bank9597
:) ทีนี้ก็อธิบายครับว่า ในไฟล์ที่แนบมานั้น มีส่วนไหนเป็นฐษนข้อมูล ส่วนไหนเป็นฟอร์ม ระบุชื่อชีทให้ชัดเจน พร้อมโค๊ดที่เขียนมาแล้วยังติดปัญหาอยู่นั้น คือโค๊ดใด

Re: วิธีจัดทำรายงานสรุปใบเสร็จรับเงิน แบบ LINK สูตร

Posted: Thu Aug 03, 2017 6:01 pm
by sirthun
snasui wrote::D ลักษณะของงานนี้ควรใช้ VBA เข้ามาจัดการ โดยทำแบบฟอร์มใบเสร็จขึ้นมาเพียงชีทเดียว มีปุ่มสำหรับการจัดเก็บข้อมูลลง Database

การทำรายงานก็จะนำข้อมูลจาก Database มาทำ ไม่ใช่นำมาจากชีทรายวันมาทำครับ

สำหรับการใช้ VBA จำเป็นต้องเขียนมาเองก่อนตามกฎการใช้บอร์ดข้อ 5 ด้านบน :roll: ติดตรงไหนค่อยถามกันต่อ
ถ้าตามกรณีนี้ จะเขียนโค้ดให้นำข้อมูลจากตาราง(ในSheet 1-21) มาลงในฟอร์ม(Sheet Daily และ Monthly) ในลักษณะไหนครับ โดยอ้างอิงจากชื่อหรือรหัสพนักงาน และวันที่ครับ โดยแยกเป็นรายบุคคล ฟอร์มในชีทSheet Daily เป็นวันเดียว ส่วน ฟอร์มในชีท Mouthly เป็นรวมทั้งเดือนครับ รบกวนอาจารย์ชี้แนะด้วยครับ

Re: วิธีจัดทำรายงานสรุปใบเสร็จรับเงิน แบบ LINK สูตร

Posted: Fri Aug 04, 2017 9:07 am
by logic
ลองกรอกตัวอย่างคำตอบด้วยมือและแนบมาด้วยครับ จะได้เห็นว่าคำตอบเป็นแบบไหน เพื่อน ๆ จะได้ช่วยกันคิดต่อได้ครับ :)

Re: วิธีจัดทำรายงานสรุปใบเสร็จรับเงิน แบบ LINK สูตร

Posted: Fri Aug 04, 2017 3:17 pm
by sirthun
จากไฟล์แนบของผม ผมได้สร้างUserForm สำหรับเพิ่มข้อมูลลงตารางไว้แล้วครับ แต่ตอนนี้ยังคิดไม่ออกเลยว่าจะเอาข้อมูลไปลงในแบบฟอร์มที่ทำไว้ยังไง(worksheet Monthly,Daily) รบกวนชี้แนะผมด้วยครับ

Re: วิธีจัดทำรายงานสรุปใบเสร็จรับเงิน แบบ LINK สูตร

Posted: Sat Aug 05, 2017 6:07 pm
by snasui
:D เอาข้อมูลไปลงในตารางสามารถใช้การ Loop แต่ละเซลล์แต่ละชีตเพื่อนำค่ามาวางได้ แต่จะต้องทราบเสียก่อนว่าต้องการนำข้อมูลใด ไปไว้ที่ใด ด้วยเงื่อนไขใด คำตอบที่ถูกต้องเป็นอย่างไร คุณ logic ช่วยแจ้งไปแล้วว่าให้ทำตัวอย่างคำตอบที่ถูกต้องมาแสดงด้วยจะได้เข้าใจตรงกัน สะดวกในการตอบครับ

Re: วิธีจัดทำรายงานสรุปใบเสร็จรับเงิน แบบ LINK สูตร

Posted: Mon Aug 07, 2017 1:48 pm
by sirthun
อยู่ในSheet Daily นะครับ สำหรับเงื่อนไข กับเซลล์ที่ลงข้อมูล :D

Re: วิธีจัดทำรายงานสรุปใบเสร็จรับเงิน แบบ LINK สูตร

Posted: Mon Aug 07, 2017 8:36 pm
by snasui
:D จากตัวอย่างไฟล์คำตอบ ชีต Daily เซลล์ E5 มีค่า 120 มีวิธีคิดอย่างไรหรือนำอัตรามาจากไหน ช่วยอธิบายเพิ่มให้ครบทุกอัตราครับ :?:

Re: วิธีจัดทำรายงานสรุปใบเสร็จรับเงิน แบบ LINK สูตร

Posted: Tue Aug 08, 2017 9:34 am
by sirthun
เงื่อนไขค่าเที่ยวนะครับ
จะแบ่งตามประเภทรถ กับระยะทาง แล้วก็จำนวนเที่ยว ในตัวอย่างเป็นรถ 6 ล้อ
กรณีไม่ถึง 400 กม
เท่ี่ยว 1
พนง.ขับ 100 พนง.ติดรถ 20
เที่ยว 2
พนง.ขับ 120 พนง.ติดรถ 50
**แต่ถ้าวันนั้นทั้งวัน วิ่งแค่1เที่ยว จะคิดให้เป็นราคาเดียวกับเที่ยว 2 ครับ**
กรณี เกิน 400 กม.
ทุกเที่ยวราคาเท่ากันหมด
พนง.ขับ 200 พนง.ติดรถ 80
ปล.อยากสอบถามอาจารย์ว่า ถ้ามีเงื่อนไขเกี่ยวกับพวกประเภทรถ ประเภทพนักงาน ต้องเขียนClass รึเปล่าครับ แต่ผมได้สร้างClassไว้แล้วคือส่วนของพนักงาน(Class EmCls แล้วประกาศค่าตัวแปรในModule1) ไม่รู้ว่าทำถูกต้องรึเปล่า รบกวนอาจารย์ช่วยตรวจด้วยครับ แหะๆ :)

Re: วิธีจัดทำรายงานสรุปใบเสร็จรับเงิน แบบ LINK สูตร

Posted: Tue Aug 08, 2017 10:39 pm
by snasui
:D กรณีคำถามเกี่ยวกับ Class ผมเห็นว่าไม่จำเป็นต้องสร้างเป็น Class แต่หากสร้างมาแล้วและใช้งานได้ก็ย่อมจะใช้การได้ครับ

กรณีของการทำรายงานเป็นรายวันและรายเดือน ยังไม่มีการเขียน Code มาแต่อย่างใด ผมจึงตอบเป็นสูตรมาให้ โดยมีวิธีการตามด้านล่าง

ให้เพิ่มชีตมา 1 ชีตสมมุติว่าชื่อ Sheet1 เพื่อนำข้อมูลทั้งหมดมาเรียงต่อกันด้วยสูตรด้านล่าง
  1. K2:K32 คีย์เลข 1-31
  2. L2 คีย์สูตร
    =COUNT(INDIRECT("'"&K2&"'!A:A"))
    Enter > Copy ลงด้านล่างถึง L32
  3. L33 คีย์สูตร
    =SUM(L2:L32)
    Enter
  4. M2 คีย์สูตร=SUM(L$2:L2)-L2+1
    Enter > Copy ลงด้านล่างถึง M32
  5. I2 คีย์สูตร
    =IF(ROWS(I$2:I2)>$L$33,"",LOOKUP(ROWS(I$2:I2),$M$2:$M$32,$K$2:$K$32))
    Enter > Copy ลงด้านล่างจนได้ผลลัพธ์เป็นค่าว่าง
  6. A2 คีย์สูตร
    =IF($I2="","",OFFSET(INDIRECT("'"&$I2&"'!A2"),COUNTIF($I$2:$I2,$I2)-1,COLUMNS($A2:A2)-1))
    Enter > Copy ไปด้านขวาถึง G2 แล้ว Copy ลงด้านล่างจนได้ผลลัพธ์เป็นค่าว่าง
  7. H2 คีย์สูตร
    =IF(I2<>"",A2&B2&C2,"")
    Enter > Copy ลงด้านล่างจนได้ผลลัพธ์เป็นค่าว่าง
ที่ชีต Monthly
  1. A6 คีย์สูตร
    =IFERROR(INDEX(Sheet1!A$2:A$20,SMALL(IF(FREQUENCY(MATCH("~"&Sheet1!$H$2:$H$20,Sheet1!$H$2:$H$20&"",0),ROW(Sheet1!$H$2:$H$20)-ROW(Sheet1!$H$2)+1),ROW(Sheet1!$H$2:$H$20)-ROW(Sheet1!$H$2)+1),ROWS(A$6:A6))),"")
    Ctrl+Shift+Enter > Copy ลงด้านล่าง
  2. B6 คีย์สูตร
    =IFERROR(INDEX(Sheet1!B$2:B$20,SMALL(IF(FREQUENCY(MATCH("~"&Sheet1!$H$2:$H$20,Sheet1!$H$2:$H$20&"",0),ROW(Sheet1!$H$2:$H$20)-ROW(Sheet1!$H$2)+1),ROW(Sheet1!$H$2:$H$20)-ROW(Sheet1!$H$2)+1),ROWS(B$6:B6))),"")
    Ctrl+Shift+Enter > Copy ลงด้านล่าง
  3. C6 คีย์สูตร
    =IFERROR(INDEX(Sheet1!C$2:C$20,SMALL(IF(FREQUENCY(MATCH("~"&Sheet1!$H$2:$H$20,Sheet1!$H$2:$H$20&"",0),ROW(Sheet1!$H$2:$H$20)-ROW(Sheet1!$H$2)+1),ROW(Sheet1!$H$2:$H$20)-ROW(Sheet1!$H$2)+1),ROWS(C$6:C6))),"")
    Ctrl+Shift+Enter > Copy ลงด้านล่าง
  4. D6 คีย์สูตร
    =IFERROR(INDEX(Sheet1!D$2:D$20,SMALL(IF(FREQUENCY(MATCH("~"&Sheet1!$H$2:$H$20,Sheet1!$H$2:$H$20&"",0),ROW(Sheet1!$H$2:$H$20)-ROW(Sheet1!$H$2)+1),ROW(Sheet1!$H$2:$H$20)-ROW(Sheet1!$H$2)+1),ROWS(D$6:D6))),"")
    Ctrl+Shift+Enter > Copy ลงด้านล่าง
  5. M6 คีย์สูตร
    =IFERROR(INDEX(Sheet1!G$2:G$20,SMALL(IF(FREQUENCY(MATCH("~"&Sheet1!$H$2:$H$20,Sheet1!$H$2:$H$20&"",0),ROW(Sheet1!$H$2:$H$20)-ROW(Sheet1!$H$2)+1),ROW(Sheet1!$H$2:$H$20)-ROW(Sheet1!$H$2)+1),ROWS(M$6:M6))),"")
    Ctrl+Shift+Enter > Copy ลงด้านล่าง
  6. J6 คีย์สูตร
    =SUMIFS(Sheet1!$F$2:$F$20,Sheet1!$H$2:$H$20,$A6&$B6&$C6,Sheet1!$E$2:$E$20,RIGHT(J$5))
    Enter > Copy ลงด้านล่าง
  7. K6 คีย์สูตร
    =SUMIFS(Sheet1!$F$2:$F$20,Sheet1!$H$2:$H$20,$A6&$B6&$C6,Sheet1!$E$2:$E$20,RIGHT(K$5))
    Enter > Copy ลงด้านล่าง
  8. L6 คีย์สูตร
    =SUMIFS(Sheet1!$F$2:$F$20,Sheet1!$H$2:$H$20,$A6&$B6&$C6,Sheet1!$E$2:$E$20,RIGHT(L$5))
    Enter > Copy ลงด้านล่าง
ให้ลองนำไปประยุกต์ใช้กับชีตรายวัน ในส่วนของจำนวนเงินค่าเที่ยวเกี่ยวกับประเภทรถ ไม่ทราบว่าดูจากเซลล์ไหน ชีตไหน ว่ารายการปัจจุบันเป็นรถประเภทใด ช่วยแจ้งมาอีกรอบครับ

!
Note: Ctrl+Shift+Enter เป็นการสร้างสูตร Array โดยสามารถเลือกดำเนินการตามข้อ 1 หรือ 2 ด้านล่าง
  1. กรณีคีย์สูตรเอง เมื่อคีย์สูตรแล้ว แทนที่จะกด Enter ให้กดแป้น Ctrl และ Shift พร้อมกันค้างไว้แล้วกด Enter เพื่อสร้างเป็นสูตร Array
  2. กรณี Copy สูตรไปวางให้กดแป้น F2 เพื่อทำการ Edit Cell นั้นก่อน จากนั้นกดแป้น Ctrl และ Shift พร้อมกันค้างไว้แล้วตามด้วย Enter เพื่อสร้างเป็นสูตร Array
  3. หากกดแป้นถูกต้องสูตรนั้นจะมีเครื่องหมายปีกกาครอบ เช่น {=YourFormulas(...)} ปีกกานี้ไม่สามารถคีย์เข้าไปเอง จะต้องมาด้วยการกดแป้น Ctrl+Shift+Enter เท่านั้น ถ้ายังไม่เห็นปีกกาครอบสูตรแสดงว่ากดแป้นให้รับสูตรไม่ถูกต้อง
  4. การแก้ไขเปลี่ยนแปลงสูตร Array จะต้องกดแป้นให้รับสูตรด้วย Ctrl+Shift+Enter ทุกครั้ง

Re: วิธีจัดทำรายงานสรุปใบเสร็จรับเงิน แบบ LINK สูตร

Posted: Wed Aug 09, 2017 11:33 am
by sirthun
ขอบคุณอาจารย์เรื่องสูตรการlookup ครับ เป็นสูตรที่สุดยอดมากๆครับ
เรื่องการคำนวนค่าเที่ยว ครั้งแรกผมคิดว่าจะใช้สูตรคำนวนในvbเลย โดยคิดจากระยะ ที่ใส่เข้าไปในชีทรายบุคคลของพนักงาน 1-21 ตามเงื่อนไข
กรณีไม่ถึง 400 กม
เท่ี่ยว 1
พนง.ขับ 100 พนง.ติดรถ 20
เที่ยว 2
พนง.ขับ 120 พนง.ติดรถ 50
**แต่ถ้าวันนั้นทั้งวัน วิ่งแค่1เที่ยว จะคิดให้เป็นราคาเดียวกับเที่ยว 2 ครับ**
กรณี เกิน 400 กม.
ทุกเที่ยวราคาเท่ากันหมด
พนง.ขับ 200 พนง.ติดรถ 80
แต่น่าจะทำสูตรคำนวนในชีทง่ายกว่าใช่ไหมครับ
ในส่วนของประเภทรถ ยังไม่ได้ทำครับ แต่เขียนไว้ในClassแล้ว กะว่าจะทำการคำนวนในvbทั้งหมดเลย
ประมาณนี้ได้ไหมครับ

Code: Select all

Sub Calculate()
    With Worksheets("1")
    If Range("F2") <= 399 Then
        Range("H2") = 120
        ElseIf Range("F2") <= 600 Then
            Range("H2") = 200
    End If
    End With
End Sub
ถ้ามีวิธีไหนที่ดีกว่ารบกวนอาจารย์ช่วยชี้แนะด้วยครับ

Re: วิธีจัดทำรายงานสรุปใบเสร็จรับเงิน แบบ LINK สูตร

Posted: Wed Aug 09, 2017 5:25 pm
by sirthun
เพิ่มเติมครับ สำหรับเงื่อนไขคำนวณค่าเที่ยว

Code: Select all

'SizeL
        If UserForm1.ComboBox1.Value = Car1.CarLicen And UserForm1.TextBox2.Value = 1 And UserForm1.TextBox3.Value <= 399 Then
            ws.Cells(i, 7) = range1L
            ElseIf UserForm1.ComboBox1.Value = Car1.CarLicen And UserForm1.TextBox2.Value = 2 And UserForm1.TextBox3.Value <= 399 Then
                ws.Cells(i, 7) = range2L
                ElseIf UserForm1.ComboBox1.Value = Car1.CarLicen And UserForm1.TextBox2.Value = 3 And UserForm1.TextBox3.Value <= 399 Then
                    ws.Cells(i, 7) = range3L
                    ElseIf UserForm1.ComboBox1.Value = Car1.CarLicen And UserForm1.TextBox3.Value <= 600 Then
                        ws.Cells(i, 7) = rangeOver1
                        ElseIf UserForm1.ComboBox1.Value = Car1.CarLicen And UserForm1.TextBox3.Value <= 800 Then
                            ws.Cells(i, 7) = rangeOver2
                            ElseIf UserForm1.ComboBox1.Value = Car1.CarLicen And UserForm1.TextBox3.Value <= 1000 Then
                                ws.Cells(i, 7) = rangeOver3
                                ElseIf UserForm1.ComboBox1.Value = Car1.CarLicen And UserForm1.TextBox3.Value <= 1499 Then
                                    ws.Cells(i, 7) = rangeOver4
                                        ElseIf UserForm1.ComboBox1.Value = Car1.CarLicen And UserForm1.TextBox3.Value >= 1500 Then
                                            ws.Cells(i, 7) = rangeOver5
        End If
        If UserForm1.ComboBox1.Value = Car2.CarLicen And UserForm1.TextBox2.Value = 1 And UserForm1.TextBox3.Value <= 399 Then
            ws.Cells(i, 7) = range1L
            ElseIf UserForm1.ComboBox1.Value = Car2.CarLicen And UserForm1.TextBox2.Value = 2 And UserForm1.TextBox3.Value <= 399 Then
                ws.Cells(i, 7) = range2L
                ElseIf UserForm1.ComboBox1.Value = Car2.CarLicen And UserForm1.TextBox2.Value = 3 And UserForm1.TextBox3.Value <= 399 Then
                    ws.Cells(i, 7) = range3L
                    ElseIf UserForm1.ComboBox1.Value = Car2.CarLicen And UserForm1.TextBox3.Value <= 600 Then
                        ws.Cells(i, 7) = rangeOver1
                        ElseIf UserForm1.ComboBox1.Value = Car2.CarLicen And UserForm1.TextBox3.Value <= 800 Then
                            ws.Cells(i, 7) = rangeOver2
                            ElseIf UserForm1.ComboBox1.Value = Car2.CarLicen And UserForm1.TextBox3.Value <= 1000 Then
                                ws.Cells(i, 7) = rangeOver3
                                ElseIf UserForm1.ComboBox1.Value = Car2.CarLicen And UserForm1.TextBox3.Value <= 1499 Then
                                    ws.Cells(i, 7) = rangeOver4
                                        ElseIf UserForm1.ComboBox1.Value = Car2.CarLicen And UserForm1.TextBox3.Value >= 1500 Then
                                            ws.Cells(i, 7) = rangeOver5
        End If
        If UserForm1.ComboBox1.Value = Car3.CarLicen And UserForm1.TextBox2.Value = 1 And UserForm1.TextBox3.Value <= 399 Then
            ws.Cells(i, 7) = range1L
            ElseIf UserForm1.ComboBox1.Value = Car3.CarLicen And UserForm1.TextBox2.Value = 2 And UserForm1.TextBox3.Value <= 399 Then
                ws.Cells(i, 7) = range2L
                ElseIf UserForm1.ComboBox1.Value = Car3.CarLicen And UserForm1.TextBox2.Value = 3 And UserForm1.TextBox3.Value <= 399 Then
                    ws.Cells(i, 7) = range3L
                    ElseIf UserForm1.ComboBox1.Value = Car3.CarLicen And UserForm1.TextBox3.Value <= 600 Then
                        ws.Cells(i, 7) = rangeOver1
                        ElseIf UserForm1.ComboBox1.Value = Car3.CarLicen And UserForm1.TextBox3.Value <= 800 Then
                            ws.Cells(i, 7) = rangeOver2
                            ElseIf UserForm1.ComboBox1.Value = Car3.CarLicen And UserForm1.TextBox3.Value <= 1000 Then
                                ws.Cells(i, 7) = rangeOver3
                                ElseIf UserForm1.ComboBox1.Value = Car3.CarLicen And UserForm1.TextBox3.Value <= 1499 Then
                                    ws.Cells(i, 7) = rangeOver4
                                        ElseIf UserForm1.ComboBox1.Value = Car3.CarLicen And UserForm1.TextBox3.Value >= 1500 Then
                                            ws.Cells(i, 7) = rangeOver5
        End If
        If UserForm1.ComboBox1.Value = Car4.CarLicen And UserForm1.TextBox2.Value = 1 And UserForm1.TextBox3.Value <= 399 Then
            ws.Cells(i, 7) = range1L
            ElseIf UserForm1.ComboBox1.Value = Car4.CarLicen And UserForm1.TextBox2.Value = 2 And UserForm1.TextBox3.Value <= 399 Then
                ws.Cells(i, 7) = range2L
                ElseIf UserForm1.ComboBox1.Value = Car4.CarLicen And UserForm1.TextBox2.Value = 3 And UserForm1.TextBox3.Value <= 399 Then
                    ws.Cells(i, 7) = range3L
                    ElseIf UserForm1.ComboBox1.Value = Car4.CarLicen And UserForm1.TextBox3.Value <= 600 Then
                        ws.Cells(i, 7) = rangeOver1
                        ElseIf UserForm1.ComboBox1.Value = Car4.CarLicen And UserForm1.TextBox3.Value <= 800 Then
                            ws.Cells(i, 7) = rangeOver2
                            ElseIf UserForm1.ComboBox1.Value = Car4.CarLicen And UserForm1.TextBox3.Value <= 1000 Then
                                ws.Cells(i, 7) = rangeOver3
                                ElseIf UserForm1.ComboBox1.Value = Car4.CarLicen And UserForm1.TextBox3.Value <= 1499 Then
                                    ws.Cells(i, 7) = rangeOver4
                                        ElseIf UserForm1.ComboBox1.Value = Car4.CarLicen And UserForm1.TextBox3.Value >= 1500 Then
                                            ws.Cells(i, 7) = rangeOver5
        End If
        If UserForm1.ComboBox1.Value = Car5.CarLicen And UserForm1.TextBox2.Value = 1 And UserForm1.TextBox3.Value <= 399 Then
            ws.Cells(i, 7) = range1L
            ElseIf UserForm1.ComboBox1.Value = Car5.CarLicen And UserForm1.TextBox2.Value = 2 And UserForm1.TextBox3.Value <= 399 Then
                ws.Cells(i, 7) = range2L
                ElseIf UserForm1.ComboBox1.Value = Car5.CarLicen And UserForm1.TextBox2.Value = 3 And UserForm1.TextBox3.Value <= 399 Then
                    ws.Cells(i, 7) = range3L
                    ElseIf UserForm1.ComboBox1.Value = Car5.CarLicen And UserForm1.TextBox3.Value <= 600 Then
                        ws.Cells(i, 7) = rangeOver1
                        ElseIf UserForm1.ComboBox1.Value = Car5.CarLicen And UserForm1.TextBox3.Value <= 800 Then
                            ws.Cells(i, 7) = rangeOver2
                            ElseIf UserForm1.ComboBox1.Value = Car5.CarLicen And UserForm1.TextBox3.Value <= 1000 Then
                                ws.Cells(i, 7) = rangeOver3
                                ElseIf UserForm1.ComboBox1.Value = Car5.CarLicen And UserForm1.TextBox3.Value <= 1499 Then
                                    ws.Cells(i, 7) = rangeOver4
                                        ElseIf UserForm1.ComboBox1.Value = Car5.CarLicen And UserForm1.TextBox3.Value >= 1500 Then
                                            ws.Cells(i, 7) = rangeOver5
        End If
        If UserForm1.ComboBox1.Value = Car6.CarLicen And UserForm1.TextBox2.Value = 1 And UserForm1.TextBox3.Value <= 399 Then
            ws.Cells(i, 7) = range1L
            ElseIf UserForm1.ComboBox1.Value = Car6.CarLicen And UserForm1.TextBox2.Value = 2 And UserForm1.TextBox3.Value <= 399 Then
                ws.Cells(i, 7) = range2L
                ElseIf UserForm1.ComboBox1.Value = Car6.CarLicen And UserForm1.TextBox2.Value = 3 And UserForm1.TextBox3.Value <= 399 Then
                    ws.Cells(i, 7) = range3L
                    ElseIf UserForm1.ComboBox1.Value = Car6.CarLicen And UserForm1.TextBox3.Value <= 600 Then
                        ws.Cells(i, 7) = rangeOver1
                        ElseIf UserForm1.ComboBox1.Value = Car6.CarLicen And UserForm1.TextBox3.Value <= 800 Then
                            ws.Cells(i, 7) = rangeOver2
                            ElseIf UserForm1.ComboBox1.Value = Car6.CarLicen And UserForm1.TextBox3.Value <= 1000 Then
                                ws.Cells(i, 7) = rangeOver3
                                ElseIf UserForm1.ComboBox1.Value = Car6.CarLicen And UserForm1.TextBox3.Value <= 1499 Then
                                    ws.Cells(i, 7) = rangeOver4
                                        ElseIf UserForm1.ComboBox1.Value = Car6.CarLicen And UserForm1.TextBox3.Value >= 1500 Then
                                            ws.Cells(i, 7) = rangeOver5
        End If
    'SizeM
        If UserForm1.ComboBox1.Value = Car7.CarLicen And UserForm1.TextBox2.Value = 1 And UserForm1.TextBox3.Value <= 399 Then
            ws.Cells(i, 7) = range1M
            ElseIf UserForm1.ComboBox1.Value = Car7.CarLicen And UserForm1.TextBox2.Value = 2 And UserForm1.TextBox3.Value <= 399 Then
                ws.Cells(i, 7) = range2M
                ElseIf UserForm1.ComboBox1.Value = Car7.CarLicen And UserForm1.TextBox2.Value = 3 And UserForm1.TextBox3.Value <= 399 Then
                    ws.Cells(i, 7) = range2M
                    ElseIf UserForm1.ComboBox1.Value = Car7.CarLicen And UserForm1.TextBox3.Value <= 600 Then
                        ws.Cells(i, 7) = rangeOver1
                        ElseIf UserForm1.ComboBox1.Value = Car7.CarLicen And UserForm1.TextBox3.Value <= 800 Then
                            ws.Cells(i, 7) = rangeOver2
                            ElseIf UserForm1.ComboBox1.Value = Car7.CarLicen And UserForm1.TextBox3.Value <= 1000 Then
                                ws.Cells(i, 7) = rangeOver3
                                ElseIf UserForm1.ComboBox1.Value = Car7.CarLicen And UserForm1.TextBox3.Value <= 1499 Then
                                    ws.Cells(i, 7) = rangeOver4
                                        ElseIf UserForm1.ComboBox1.Value = Car7.CarLicen And UserForm1.TextBox3.Value >= 1500 Then
                                            ws.Cells(i, 7) = rangeOver5
        End If
        If UserForm1.ComboBox1.Value = Car8.CarLicen And UserForm1.TextBox2.Value = 1 And UserForm1.TextBox3.Value <= 399 Then
            ws.Cells(i, 7) = range1M
            ElseIf UserForm1.ComboBox1.Value = Car8.CarLicen And UserForm1.TextBox2.Value = 2 And UserForm1.TextBox3.Value <= 399 Then
                ws.Cells(i, 7) = range2M
                ElseIf UserForm1.ComboBox1.Value = Car8.CarLicen And UserForm1.TextBox2.Value = 3 And UserForm1.TextBox3.Value <= 399 Then
                    ws.Cells(i, 7) = range2M
                    ElseIf UserForm1.ComboBox1.Value = Car8.CarLicen And UserForm1.TextBox3.Value <= 600 Then
                        ws.Cells(i, 7) = rangeOver1
                        ElseIf UserForm1.ComboBox1.Value = Car8.CarLicen And UserForm1.TextBox3.Value <= 800 Then
                            ws.Cells(i, 7) = rangeOver2
                            ElseIf UserForm1.ComboBox1.Value = Car8.CarLicen And UserForm1.TextBox3.Value <= 1000 Then
                                ws.Cells(i, 7) = rangeOver3
                                ElseIf UserForm1.ComboBox1.Value = Car8.CarLicen And UserForm1.TextBox3.Value <= 1499 Then
                                    ws.Cells(i, 7) = rangeOver4
                                        ElseIf UserForm1.ComboBox1.Value = Car8.CarLicen And UserForm1.TextBox3.Value >= 1500 Then
                                            ws.Cells(i, 7) = rangeOver5
        End If
        If UserForm1.ComboBox1.Value = Car9.CarLicen And UserForm1.TextBox2.Value = 1 And UserForm1.TextBox3.Value <= 399 Then
            ws.Cells(i, 7) = range1M
            ElseIf UserForm1.ComboBox1.Value = Car9.CarLicen And UserForm1.TextBox2.Value = 2 And UserForm1.TextBox3.Value <= 399 Then
                ws.Cells(i, 7) = range2M
                ElseIf UserForm1.ComboBox1.Value = Car9.CarLicen And UserForm1.TextBox2.Value = 3 And UserForm1.TextBox3.Value <= 399 Then
                    ws.Cells(i, 7) = range2M
                    ElseIf UserForm1.ComboBox1.Value = Car9.CarLicen And UserForm1.TextBox3.Value <= 600 Then
                        ws.Cells(i, 7) = rangeOver1
                        ElseIf UserForm1.ComboBox1.Value = Car9.CarLicen And UserForm1.TextBox3.Value <= 800 Then
                            ws.Cells(i, 7) = rangeOver2
                            ElseIf UserForm1.ComboBox1.Value = Car9.CarLicen And UserForm1.TextBox3.Value <= 1000 Then
                                ws.Cells(i, 7) = rangeOver3
                                ElseIf UserForm1.ComboBox1.Value = Car9.CarLicen And UserForm1.TextBox3.Value <= 1499 Then
                                    ws.Cells(i, 7) = rangeOver4
                                        ElseIf UserForm1.ComboBox1.Value = Car9.CarLicen And UserForm1.TextBox3.Value >= 1500 Then
                                            ws.Cells(i, 7) = rangeOver5
        End If
    'SizeS
        If UserForm1.ComboBox1.Value = Car10.CarLicen And UserForm1.TextBox2.Value = 1 And UserForm1.TextBox3.Value <= 399 Then
            ws.Cells(i, 7) = range1S
            ElseIf UserForm1.ComboBox1.Value = Car10.CarLicen And UserForm1.TextBox2.Value = 2 And UserForm1.TextBox3.Value <= 399 Then
                ws.Cells(i, 7) = range2S
                ElseIf UserForm1.ComboBox1.Value = Car10.CarLicen And UserForm1.TextBox2.Value = 3 And UserForm1.TextBox3.Value <= 399 Then
                    ws.Cells(i, 7) = range2S
                    ElseIf UserForm1.ComboBox1.Value = Car10.CarLicen And UserForm1.TextBox3.Value <= 600 Then
                        ws.Cells(i, 7) = rangeOver1
                        ElseIf UserForm1.ComboBox1.Value = Car10.CarLicen And UserForm1.TextBox3.Value <= 800 Then
                            ws.Cells(i, 7) = rangeOver2
                            ElseIf UserForm1.ComboBox1.Value = Car10.CarLicen And UserForm1.TextBox3.Value <= 1000 Then
                                ws.Cells(i, 7) = rangeOver3
                                ElseIf UserForm1.ComboBox1.Value = Car10.CarLicen And UserForm1.TextBox3.Value <= 1499 Then
                                    ws.Cells(i, 7) = rangeOver4
                                        ElseIf UserForm1.ComboBox1.Value = Car10.CarLicen And UserForm1.TextBox3.Value >= 1500 Then
                                            ws.Cells(i, 7) = rangeOver5
        End If
        If UserForm1.ComboBox1.Value = Car11.CarLicen And UserForm1.TextBox2.Value = 1 And UserForm1.TextBox3.Value <= 399 Then
            ws.Cells(i, 7) = range1S
            ElseIf UserForm1.ComboBox1.Value = Car11.CarLicen And UserForm1.TextBox2.Value = 2 And UserForm1.TextBox3.Value <= 399 Then
                ws.Cells(i, 7) = range2S
                ElseIf UserForm1.ComboBox1.Value = Car11.CarLicen And UserForm1.TextBox2.Value = 3 And UserForm1.TextBox3.Value <= 399 Then
                    ws.Cells(i, 7) = range2S
                    ElseIf UserForm1.ComboBox1.Value = Car11.CarLicen And UserForm1.TextBox3.Value <= 600 Then
                        ws.Cells(i, 7) = rangeOver1
                        ElseIf UserForm1.ComboBox1.Value = Car11.CarLicen And UserForm1.TextBox3.Value <= 800 Then
                            ws.Cells(i, 7) = rangeOver2
                            ElseIf UserForm1.ComboBox1.Value = Car11.CarLicen And UserForm1.TextBox3.Value <= 1000 Then
                                ws.Cells(i, 7) = rangeOver3
                                ElseIf UserForm1.ComboBox1.Value = Car11.CarLicen And UserForm1.TextBox3.Value <= 1499 Then
                                    ws.Cells(i, 7) = rangeOver4
                                        ElseIf UserForm1.ComboBox1.Value = Car11.CarLicen And UserForm1.TextBox3.Value >= 1500 Then
                                            ws.Cells(i, 7) = rangeOver5
        End If

Re: วิธีจัดทำรายงานสรุปใบเสร็จรับเงิน แบบ LINK สูตร

Posted: Wed Aug 09, 2017 6:18 pm
by snasui
:D ตามโพสต์ #16 ยังติดขัดส่วนใดหรือไม่ อย่างไรหรือสามารถหาคำตอบได้แล้ว ช่วยแจ้งมาด้วยครับ

เมื่อมีการใช้ UserForm ในการรับค่า Input เราสามารถคำนวณค่าเที่ยวจากการกรอกข้อมูลของผู้ใช้ในขั้นตอนการ Input ก็ได้เช่นกัน จะได้ไม่ต้องมาคำนวณภายหลัง หรือติดเงื่อนไขใดจึงไม่สามารถคำนวณเมื่อมีการ Input ข้อมูลได้ครับ

Re: วิธีจัดทำรายงานสรุปใบเสร็จรับเงิน แบบ LINK สูตร

Posted: Thu Aug 10, 2017 2:27 pm
by sirthun
snasui wrote::D ตามโพสต์ #16 ยังติดขัดส่วนใดหรือไม่ อย่างไรหรือสามารถหาคำตอบได้แล้ว ช่วยแจ้งมาด้วยครับ

เมื่อมีการใช้ UserForm ในการรับค่า Input เราสามารถคำนวณค่าเที่ยวจากการกรอกข้อมูลของผู้ใช้ในขั้นตอนการ Input ก็ได้เช่นกัน จะได้ไม่ต้องมาคำนวณภายหลัง หรือติดเงื่อนไขใดจึงไม่สามารถคำนวณเมื่อมีการ Input ข้อมูลได้ครับ
ไม่ติดปัญหาแล้วครับอาจารย์ เรื่องการคำนวนค่าเที่ยว :D ขอบคุณอาจารย์มากครับ :cp: