โจทก์ที่แก้ได้แล้ว คือ
นำข้อมูลจาก Cell ไปเทียบ เมื่อเจอ ข้อมูลที่ตรงกันแล้วจะนำ input ไปใส่ให้ถูกต้อง
แต่สามารถ ตรวจสอบได้เพียง 1 ข้อมูล ( 1 criteria หรือ มากกว่าสามารถทำได้แล้วครับ)
แต่ในกรณีนี้ข้อมูลที่ต้องการตรวจสอบมีมากกว่า 1 ข้อมูล
ผมจึงต้องสร้างฟังชันแต่ละ row ข้อมูลเพื่อนำไปตรวจสอบแล้วใช้ อีกฟังชันหนึ่งเพื่อเรียกใช้งานฟังชันทั้งหมด
ปัญหา
ถ้าผมต้องการ สร้างฟังชันเพื่อ loop ให้ครบตามจำนวนrow ที่มีข้อมูลต้องแก้ อย่างไรครับ
Code: Select all
Sub update_vol2()
Dim ship As Long
Dim r_ship As Long
Dim p_fuelvol As Long
Dim p_select As Integer
Dim p_lube As Long
Dim i As Integer
i = 4
'ตรงนี้ที่มีปันหาคือจะต้องสร้างฟังชันเพิ่มไปเครื่องๆตามจำนวนrowที่มีข้อมูล ถ้ามี ไม่เยอะก็พอไหวแต่ถ้ามีเป็น100ควรจะต้องทำอย่างไรครับ
ship = Sheets("Cluster Summary").Cells(26, 11).Value
p_fuelvol = Sheets("Cluster Summary").Cells(26, 12).Value
p_select = Sheets("Cluster Summary").Cells(26, 13).Value
p_lube = Sheets("Cluster Summary").Cells(26, 14).Value
r_ship = Sheets("Cal Sheet").Cells(i, 6).Value
Do
If ship = r_ship Then
Sheets("Cal Sheet").Cells(i, 12).Value = p_fuelvol * 12
Sheets("Cal Sheet").Cells(i, 13).Value = p_select * 12
Sheets("Cal Sheet").Cells(i, 14).Value = p_lube * 12
End If
i = i + 1
r_ship = Sheets("Cal Sheet").Cells(i, 6).Value
Loop Until r_ship = 0
End Sub
You do not have the required permissions to view the files attached to this post.