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
Sub CopyByTime()
'
' CopyByTime Macro
'
'
If Sheets("Master").Range("d2").Value > Sheets("Master").Range("a1").Value And Sheets("Master").Range("a1").Value >= Sheets("Master").Range("c2").Value Then
Sheets("DataPaste").Select
Range("A1").Select
Sheets("BZ_RTD").Select
Range("A1:A51,C1:C51,F1:G51").Select
Selection.Copy
Sheets("DataPaste").Select
Range("A1").Select
ActiveSheet.Paste
Range("A1").Select
Sheets("BZ_RTD").Select
Range("A1:A51,C1:C51").Select
Selection.Copy
Sheets("Deal").Select
Range("A1").Select
ActiveSheet.Paste
Range("A1").Select
Sheets("BZ_RTD").Select
Range("A1:A51,F1:F51").Select
Selection.Copy
Sheets("Vbuy").Select
Range("A1").Select
ActiveSheet.Paste
Range("A1").Select
Sheets("BZ_RTD").Select
Range("A1:A51,G1:G51").Select
Selection.Copy
Sheets("Vsell").Select
Range("A1").Select
ActiveSheet.Paste
Range("A1").Select
End If
If Sheets("Master").Range("d3").Value > Sheets("Master").Range("a1").Value And Sheets("Master").Range("a1").Value >= Sheets("Master").Range("c3").Value Then
Sheets("BZ_RTD").Select
Range("C1:C51,F1:G51").Select
Selection.Copy
Sheets("DataPaste").Select
Range("E1").Select
ActiveSheet.Paste
Range("E1").Select
Sheets("BZ_RTD").Select
Range("C1:C51").Select
Selection.Copy
Sheets("Deal").Select
Range("C1").Select
ActiveSheet.Paste
Range("C1").Select
Sheets("BZ_RTD").Select
Range("F1:F51").Select
Selection.Copy
Sheets("Vbuy").Select
Range("C1").Select
ActiveSheet.Paste
Range("C1").Select
Sheets("BZ_RTD").Select
Range("G1:G51").Select
Selection.Copy
Sheets("Vsell").Select
Range("C1").Select
ActiveSheet.Paste
Range("C1").Select
End If
If Sheets("Master").Range("d4").Value > Sheets("Master").Range("a1").Value And Sheets("Master").Range("a1").Value >= Sheets("Master").Range("c4").Value Then
Sheets("BZ_RTD").Select
Range("C1:C51,F1:G51").Select
Selection.Copy
Sheets("DataPaste").Select
Range("h1").Select
ActiveSheet.Paste
Range("h1").Select
Sheets("BZ_RTD").Select
Range("C1:C51").Select
Selection.Copy
Sheets("Deal").Select
Range("D1").Select
ActiveSheet.Paste
Range("D1").Select
Sheets("BZ_RTD").Select
Range("F1:F51").Select
Selection.Copy
Sheets("Vbuy").Select
Range("D1").Select
ActiveSheet.Paste
Range("D1").Select
Sheets("BZ_RTD").Select
Range("G1:G51").Select
Selection.Copy
Sheets("Vsell").Select
Range("D1").Select
ActiveSheet.Paste
Range("D1").Select
End If
If Sheets("Master").Range("d5").Value > Sheets("Master").Range("a1").Value And Sheets("Master").Range("a1").Value >= Sheets("Master").Range("c5").Value Then
Sheets("BZ_RTD").Select
Range("C1:C51,F1:G51").Select
Selection.Copy
Sheets("DataPaste").Select
Range("k1").Select
ActiveSheet.Paste
Range("k1").Select
Sheets("BZ_RTD").Select
Range("C1:C51").Select
Selection.Copy
Sheets("Deal").Select
Range("e1").Select
ActiveSheet.Paste
Range("e1").Select
Sheets("BZ_RTD").Select
Range("F1:F51").Select
Selection.Copy
Sheets("Vbuy").Select
Range("e1").Select
ActiveSheet.Paste
Range("e1").Select
Sheets("BZ_RTD").Select
Range("G1:G51").Select
Selection.Copy
Sheets("Vsell").Select
Range("e1").Select
ActiveSheet.Paste
Range("e1").Select
End If
If Sheets("Master").Range("d6").Value > Sheets("Master").Range("a1").Value And Sheets("Master").Range("a1").Value >= Sheets("Master").Range("c6").Value Then
Sheets("BZ_RTD").Select
Range("C1:C51,F1:G51").Select
Selection.Copy
Sheets("DataPaste").Select
Range("n1").Select
ActiveSheet.Paste
Range("n1").Select
Sheets("BZ_RTD").Select
Range("C1:C51").Select
Selection.Copy
Sheets("Deal").Select
Range("f1").Select
ActiveSheet.Paste
Range("f1").Select
Sheets("BZ_RTD").Select
Range("F1:F51").Select
Selection.Copy
Sheets("Vbuy").Select
Range("f1").Select
ActiveSheet.Paste
Range("f1").Select
Sheets("BZ_RTD").Select
Range("G1:G51").Select
Selection.Copy
Sheets("Vsell").Select
Range("f1").Select
ActiveSheet.Paste
Range("f1").Select
End If
If Sheets("Master").Range("d7").Value > Sheets("Master").Range("a1").Value And Sheets("Master").Range("a1").Value >= Sheets("Master").Range("c7").Value Then
Sheets("BZ_RTD").Select
Range("C1:C51,F1:G51").Select
Selection.Copy
Sheets("DataPaste").Select
Range("q1").Select
ActiveSheet.Paste
Range("q1").Select
Sheets("BZ_RTD").Select
Range("C1:C51").Select
Selection.Copy
Sheets("Deal").Select
Range("g1").Select
ActiveSheet.Paste
Range("g1").Select
Sheets("BZ_RTD").Select
Range("F1:F51").Select
Selection.Copy
Sheets("Vbuy").Select
Range("g1").Select
ActiveSheet.Paste
Range("g1").Select
Sheets("BZ_RTD").Select
Range("G1:G51").Select
Selection.Copy
Sheets("Vsell").Select
Range("g1").Select
ActiveSheet.Paste
Range("g1").Select
End If
'***** TBD
If Sheets("Master").Range("d8").Value > Sheets("Master").Range("a1").Value And Sheets("Master").Range("a1").Value >= Sheets("Master").Range("c8").Value Then
Sheets("BZ_RTD").Select
Range("C1:C51,F1:G51").Select
Selection.Copy
Sheets("DataPaste").Select
Range("t1").Select
ActiveSheet.Paste
Range("t1").Select
Sheets("BZ_RTD").Select
Range("C1:C51").Select
Selection.Copy
Sheets("Deal").Select
Range("t1").Select
ActiveSheet.Paste
Range("t1").Select
Sheets("BZ_RTD").Select
Range("F1:F51").Select
Selection.Copy
Sheets("Vbuy").Select
Range("t1").Select
ActiveSheet.Paste
Range("t1").Select
Sheets("BZ_RTD").Select
Range("G1:G51").Select
Selection.Copy
Sheets("Vsell").Select
Range("t1").Select
ActiveSheet.Paste
Range("t1").Select
End If
If Sheets("Master").Range("d9").Value > Sheets("Master").Range("a1").Value And Sheets("Master").Range("a1").Value >= Sheets("Master").Range("c9").Value Then
Sheets("BZ_RTD").Select
Range("C1:C51,F1:G51").Select
Selection.Copy
Sheets("DataPaste").Select
Range("w1").Select
ActiveSheet.Paste
Range("w1").Select
Sheets("BZ_RTD").Select
Range("C1:C51").Select
Selection.Copy
Sheets("Deal").Select
Range("w1").Select
ActiveSheet.Paste
Range("w1").Select
Sheets("BZ_RTD").Select
Range("F1:F51").Select
Selection.Copy
Sheets("Vbuy").Select
Range("w1").Select
ActiveSheet.Paste
Range("w1").Select
Sheets("BZ_RTD").Select
Range("G1:G51").Select
Selection.Copy
Sheets("Vsell").Select
Range("w1").Select
ActiveSheet.Paste
Range("w1").Select
End If
If Sheets("Master").Range("d10").Value > Sheets("Master").Range("a1").Value And Sheets("Master").Range("a1").Value >= Sheets("Master").Range("c10").Value Then
Sheets("BZ_RTD").Select
Range("C1:C51,F1:G51").Select
Selection.Copy
Sheets("DataPaste").Select
Range("z1").Select
ActiveSheet.Paste
Range("z1").Select
Sheets("BZ_RTD").Select
Range("C1:C51").Select
Selection.Copy
Sheets("Deal").Select
Range("z1").Select
ActiveSheet.Paste
Range("z1").Select
Sheets("BZ_RTD").Select
Range("F1:F51").Select
Selection.Copy
Sheets("Vbuy").Select
Range("z1").Select
ActiveSheet.Paste
Range("z1").Select
Sheets("BZ_RTD").Select
Range("G1:G51").Select
Selection.Copy
Sheets("Vsell").Select
Range("z1").Select
ActiveSheet.Paste
Range("z1").Select
End If
If Sheets("Master").Range("d11").Value > Sheets("Master").Range("a1").Value And Sheets("Master").Range("a1").Value >= Sheets("Master").Range("c11").Value Then
Sheets("BZ_RTD").Select
Range("C1:C51,F1:G51").Select
Selection.Copy
Sheets("DataPaste").Select
Range("ac1").Select
ActiveSheet.Paste
Range("ac1").Select
Sheets("BZ_RTD").Select
Range("C1:C51").Select
Selection.Copy
Sheets("Deal").Select
Range("ac1").Select
ActiveSheet.Paste
Range("ac1").Select
Sheets("BZ_RTD").Select
Range("F1:F51").Select
Selection.Copy
Sheets("Vbuy").Select
Range("ac1").Select
ActiveSheet.Paste
Range("ac1").Select
Sheets("BZ_RTD").Select
Range("G1:G51").Select
Selection.Copy
Sheets("Vsell").Select
Range("ac1").Select
ActiveSheet.Paste
Range("ac1").Select
End If
If Sheets("Master").Range("d12").Value > Sheets("Master").Range("a1").Value And Sheets("Master").Range("a1").Value >= Sheets("Master").Range("c12").Value Then
Sheets("BZ_RTD").Select
Range("C1:C51,F1:G51").Select
Selection.Copy
Sheets("DataPaste").Select
Range("af1").Select
ActiveSheet.Paste
Range("af1").Select
Sheets("BZ_RTD").Select
Range("C1:C51").Select
Selection.Copy
Sheets("Deal").Select
Range("af1").Select
ActiveSheet.Paste
Range("af1").Select
Sheets("BZ_RTD").Select
Range("F1:F51").Select
Selection.Copy
Sheets("Vbuy").Select
Range("af1").Select
ActiveSheet.Paste
Range("af1").Select
Sheets("BZ_RTD").Select
Range("G1:G51").Select
Selection.Copy
Sheets("Vsell").Select
Range("af1").Select
ActiveSheet.Paste
Range("af1").Select
End If
If Sheets("Master").Range("d13").Value > Sheets("Master").Range("a1").Value And Sheets("Master").Range("a1").Value >= Sheets("Master").Range("c13").Value Then
Sheets("BZ_RTD").Select
Range("C1:C51,F1:G51").Select
Selection.Copy
Sheets("DataPaste").Select
Range("ai1").Select
ActiveSheet.Paste
Range("ai1").Select
Sheets("BZ_RTD").Select
Range("C1:C51").Select
Selection.Copy
Sheets("Deal").Select
Range("ai1").Select
ActiveSheet.Paste
Range("ai1").Select
Sheets("BZ_RTD").Select
Range("F1:F51").Select
Selection.Copy
Sheets("Vbuy").Select
Range("ai1").Select
ActiveSheet.Paste
Range("ai1").Select
Sheets("BZ_RTD").Select
Range("G1:G51").Select
Selection.Copy
Sheets("Vsell").Select
Range("ai1").Select
ActiveSheet.Paste
Range("ai1").Select
End If
'*****
If Sheets("Master").Range("d14").Value > Sheets("Master").Range("a1").Value And Sheets("Master").Range("a1").Value >= Sheets("Master").Range("c14").Value Then
Sheets("BZ_RTD").Select
Range("C1:C51,F1:G51").Select
Selection.Copy
Sheets("DataPaste").Select
Range("al1").Select
ActiveSheet.Paste
Range("al1").Select
End If
If Sheets("Master").Range("d15").Value > Sheets("Master").Range("a1").Value And Sheets("Master").Range("a1").Value >= Sheets("Master").Range("c15").Value Then
Sheets("BZ_RTD").Select
Range("C1:C51,F1:G51").Select
Selection.Copy
Sheets("DataPaste").Select
Range("ao1").Select
ActiveSheet.Paste
Range("ao1").Select
End If
If Sheets("Master").Range("d16").Value > Sheets("Master").Range("a1").Value And Sheets("Master").Range("a1").Value >= Sheets("Master").Range("c16").Value Then
Sheets("BZ_RTD").Select
Range("C1:C51,F1:G51").Select
Selection.Copy
Sheets("DataPaste").Select
Range("ar1").Select
ActiveSheet.Paste
Range("ar1").Select
End If
If Sheets("Master").Range("d17").Value > Sheets("Master").Range("a1").Value And Sheets("Master").Range("a1").Value >= Sheets("Master").Range("c17").Value Then
Sheets("BZ_RTD").Select
Range("C1:C51,F1:G51").Select
Selection.Copy
Sheets("DataPaste").Select
Range("au1").Select
ActiveSheet.Paste
Range("au1").Select
End If
If Sheets("Master").Range("d18").Value > Sheets("Master").Range("a1").Value And Sheets("Master").Range("a1").Value >= Sheets("Master").Range("c18").Value Then
Sheets("BZ_RTD").Select
Range("C1:C51,F1:G51").Select
Selection.Copy
Sheets("DataPaste").Select
Range("ax1").Select
ActiveSheet.Paste
Range("ax1").Select
End If
If Sheets("Master").Range("d19").Value > Sheets("Master").Range("a1").Value And Sheets("Master").Range("a1").Value >= Sheets("Master").Range("c19").Value Then
Sheets("BZ_RTD").Select
Range("C1:C51,F1:G51").Select
Selection.Copy
Sheets("DataPaste").Select
Range("ba1").Select
ActiveSheet.Paste
Range("ba1").Select
End If
If Sheets("Master").Range("d20").Value > Sheets("Master").Range("a1").Value And Sheets("Master").Range("a1").Value >= Sheets("Master").Range("c20").Value Then
Sheets("BZ_RTD").Select
Range("C1:C51,F1:G51").Select
Selection.Copy
Sheets("DataPaste").Select
Range("bd1").Select
ActiveSheet.Paste
Range("bd1").Select
End If
If Sheets("Master").Range("d21").Value > Sheets("Master").Range("a1").Value And Sheets("Master").Range("a1").Value >= Sheets("Master").Range("c21").Value Then
Sheets("BZ_RTD").Select
Range("C1:C51,F1:G51").Select
Selection.Copy
Sheets("DataPaste").Select
Range("bg1").Select
ActiveSheet.Paste
Range("bg1").Select
End If
If Sheets("Master").Range("d22").Value > Sheets("Master").Range("a1").Value And Sheets("Master").Range("a1").Value >= Sheets("Master").Range("c22").Value Then
Sheets("BZ_RTD").Select
Range("C1:C51,F1:G51").Select
Selection.Copy
Sheets("DataPaste").Select
Range("bj1").Select
ActiveSheet.Paste
Range("bj1").Select
End If
If Sheets("Master").Range("d23").Value > Sheets("Master").Range("a1").Value And Sheets("Master").Range("a1").Value >= Sheets("Master").Range("c23").Value Then
Sheets("BZ_RTD").Select
Range("C1:C51,F1:G51").Select
Selection.Copy
Sheets("DataPaste").Select
Range("bm1").Select
ActiveSheet.Paste
Range("bm1").Select
End If
If Sheets("Master").Range("d24").Value > Sheets("Master").Range("a1").Value And Sheets("Master").Range("a1").Value >= Sheets("Master").Range("c24").Value Then
Sheets("BZ_RTD").Select
Range("C1:C51,F1:G51").Select
Selection.Copy
Sheets("DataPaste").Select
Range("bp1").Select
ActiveSheet.Paste
Range("bp1").Select
End If
If Sheets("Master").Range("d25").Value > Sheets("Master").Range("a1").Value And Sheets("Master").Range("a1").Value >= Sheets("Master").Range("c25").Value Then
Sheets("BZ_RTD").Select
Range("C1:C51,F1:G51").Select
Selection.Copy
Sheets("DataPaste").Select
Range("bs1").Select
ActiveSheet.Paste
Range("bs1").Select
End If
If Sheets("Master").Range("d26").Value > Sheets("Master").Range("a1").Value And Sheets("Master").Range("a1").Value >= Sheets("Master").Range("c26").Value Then
Sheets("BZ_RTD").Select
Range("C1:C51,F1:G51").Select
Selection.Copy
Sheets("DataPaste").Select
Range("bv1").Select
ActiveSheet.Paste
Range("bv1").Select
End If
If Sheets("Master").Range("d27").Value > Sheets("Master").Range("a1").Value And Sheets("Master").Range("a1").Value >= Sheets("Master").Range("c27").Value Then
Sheets("BZ_RTD").Select
Range("C1:C51,F1:G51").Select
Selection.Copy
Sheets("DataPaste").Select
Range("by1").Select
ActiveSheet.Paste
Range("by1").Select
End If
If Sheets("Master").Range("d28").Value > Sheets("Master").Range("a1").Value And Sheets("Master").Range("a1").Value >= Sheets("Master").Range("c28").Value Then
Sheets("BZ_RTD").Select
Range("C1:C51,F1:G51").Select
Selection.Copy
Sheets("DataPaste").Select
Range("cb1").Select
ActiveSheet.Paste
Range("cb1").Select
End If
If Sheets("Master").Range("d29").Value > Sheets("Master").Range("a1").Value And Sheets("Master").Range("a1").Value >= Sheets("Master").Range("c29").Value Then
Sheets("BZ_RTD").Select
Range("C1:C51,F1:G51").Select
Selection.Copy
Sheets("DataPaste").Select
Range("ce1").Select
ActiveSheet.Paste
Range("ce1").Select
End If
If Sheets("Master").Range("d30").Value > Sheets("Master").Range("a1").Value And Sheets("Master").Range("a1").Value >= Sheets("Master").Range("c30").Value Then
Sheets("BZ_RTD").Select
Range("C1:C51,F1:G51").Select
Selection.Copy
Sheets("DataPaste").Select
Range("ch1").Select
ActiveSheet.Paste
Range("ch1").Select
End If
If Sheets("Master").Range("d31").Value > Sheets("Master").Range("a1").Value And Sheets("Master").Range("a1").Value >= Sheets("Master").Range("c31").Value Then
Sheets("BZ_RTD").Select
Range("C1:C51,F1:G51").Select
Selection.Copy
Sheets("DataPaste").Select
Range("ck1").Select
ActiveSheet.Paste
Range("ck1").Select
End If
If Sheets("Master").Range("d32").Value > Sheets("Master").Range("a1").Value And Sheets("Master").Range("a1").Value >= Sheets("Master").Range("c32").Value Then
Sheets("BZ_RTD").Select
Range("C1:C51,F1:G51").Select
Selection.Copy
Sheets("DataPaste").Select
Range("cn1").Select
ActiveSheet.Paste
Range("cn1").Select
End If
If Sheets("Master").Range("d33").Value > Sheets("Master").Range("a1").Value And Sheets("Master").Range("a1").Value >= Sheets("Master").Range("c33").Value Then
Sheets("BZ_RTD").Select
Range("C1:C51,F1:G51").Select
Selection.Copy
Sheets("DataPaste").Select
Range("cq1").Select
ActiveSheet.Paste
Range("cq1").Select
End If
If Sheets("Master").Range("d34").Value > Sheets("Master").Range("a1").Value And Sheets("Master").Range("a1").Value >= Sheets("Master").Range("c34").Value Then
Sheets("BZ_RTD").Select
Range("C1:C51,F1:G51").Select
Selection.Copy
Sheets("DataPaste").Select
Range("ct1").Select
ActiveSheet.Paste
Range("ct1").Select
End If
If Sheets("Master").Range("d35").Value > Sheets("Master").Range("a1").Value And Sheets("Master").Range("a1").Value >= Sheets("Master").Range("c35").Value Then
Sheets("BZ_RTD").Select
Range("C1:C51,F1:G51").Select
Selection.Copy
Sheets("DataPaste").Select
Range("cw1").Select
ActiveSheet.Paste
Range("cw1").Select
End If
If Sheets("Master").Range("d36").Value > Sheets("Master").Range("a1").Value And Sheets("Master").Range("a1").Value >= Sheets("Master").Range("c36").Value Then
Sheets("BZ_RTD").Select
Range("C1:C51,F1:G51").Select
Selection.Copy
Sheets("DataPaste").Select
Range("cz1").Select
ActiveSheet.Paste
Range("cz1").Select
End If
If Sheets("Master").Range("d37").Value > Sheets("Master").Range("a1").Value And Sheets("Master").Range("a1").Value >= Sheets("Master").Range("c37").Value Then
Sheets("BZ_RTD").Select
Range("C1:C51,F1:G51").Select
Selection.Copy
Sheets("DataPaste").Select
Range("dc1").Select
ActiveSheet.Paste
Range("dc1").Select
End If
If Sheets("Master").Range("d38").Value > Sheets("Master").Range("a1").Value And Sheets("Master").Range("a1").Value >= Sheets("Master").Range("c38").Value Then
Sheets("BZ_RTD").Select
Range("C1:C51,F1:G51").Select
Selection.Copy
Sheets("DataPaste").Select
Range("df1").Select
ActiveSheet.Paste
Range("df1").Select
End If
If Sheets("Master").Range("d39").Value > Sheets("Master").Range("a1").Value And Sheets("Master").Range("a1").Value >= Sheets("Master").Range("c39").Value Then
Sheets("BZ_RTD").Select
Range("C1:C51,F1:G51").Select
Selection.Copy
Sheets("DataPaste").Select
Range("di1").Select
ActiveSheet.Paste
Range("di1").Select
End If
If Sheets("Master").Range("d40").Value > Sheets("Master").Range("a1").Value And Sheets("Master").Range("a1").Value >= Sheets("Master").Range("c40").Value Then
Sheets("BZ_RTD").Select
Range("C1:C51,F1:G51").Select
Selection.Copy
Sheets("DataPaste").Select
Range("dl1").Select
ActiveSheet.Paste
Range("dl1").Select
End If
If Sheets("Master").Range("d41").Value > Sheets("Master").Range("a1").Value And Sheets("Master").Range("a1").Value >= Sheets("Master").Range("c41").Value Then
Sheets("BZ_RTD").Select
Range("C1:C51,F1:G51").Select
Selection.Copy
Sheets("DataPaste").Select
Range("do1").Select
ActiveSheet.Paste
Range("do1").Select
End If
If Sheets("Master").Range("d42").Value > Sheets("Master").Range("a1").Value And Sheets("Master").Range("a1").Value >= Sheets("Master").Range("c42").Value Then
Sheets("BZ_RTD").Select
Range("C1:C51,F1:G51").Select
Selection.Copy
Sheets("DataPaste").Select
Range("dr1").Select
ActiveSheet.Paste
Range("dr1").Select
End If
If Sheets("Master").Range("d43").Value > Sheets("Master").Range("a1").Value And Sheets("Master").Range("a1").Value >= Sheets("Master").Range("c43").Value Then
Sheets("BZ_RTD").Select
Range("C1:C51,F1:G51").Select
Selection.Copy
Sheets("DataPaste").Select
Range("du1").Select
ActiveSheet.Paste
Range("du1").Select
End If
If Sheets("Master").Range("d44").Value > Sheets("Master").Range("a1").Value And Sheets("Master").Range("a1").Value >= Sheets("Master").Range("c44").Value Then
Sheets("BZ_RTD").Select
Range("C1:C51,F1:G51").Select
Selection.Copy
Sheets("DataPaste").Select
Range("dx1").Select
ActiveSheet.Paste
Range("dx1").Select
End If
If Sheets("Master").Range("d45").Value > Sheets("Master").Range("a1").Value And Sheets("Master").Range("a1").Value >= Sheets("Master").Range("c45").Value Then
Sheets("BZ_RTD").Select
Range("C1:C51,F1:G51").Select
Selection.Copy
Sheets("DataPaste").Select
Range("ea1").Select
ActiveSheet.Paste
Range("ea1").Select
End If
If Sheets("Master").Range("d46").Value > Sheets("Master").Range("a1").Value And Sheets("Master").Range("a1").Value >= Sheets("Master").Range("c46").Value Then
Sheets("BZ_RTD").Select
Range("C1:C51,F1:G51").Select
Selection.Copy
Sheets("DataPaste").Select
Range("ed1").Select
ActiveSheet.Paste
Range("ed1").Select
End If
If Sheets("Master").Range("d47").Value > Sheets("Master").Range("a1").Value And Sheets("Master").Range("a1").Value >= Sheets("Master").Range("c47").Value Then
Sheets("BZ_RTD").Select
Range("C1:C51,F1:G51").Select
Selection.Copy
Sheets("DataPaste").Select
Range("eg1").Select
ActiveSheet.Paste
Range("eg1").Select
End If
If Sheets("Master").Range("d48").Value > Sheets("Master").Range("a1").Value And Sheets("Master").Range("a1").Value >= Sheets("Master").Range("c48").Value Then
Sheets("BZ_RTD").Select
Range("C1:C51,F1:G51").Select
Selection.Copy
Sheets("DataPaste").Select
Range("ej1").Select
ActiveSheet.Paste
Range("ej1").Select
End If
If Sheets("Master").Range("d49").Value > Sheets("Master").Range("a1").Value And Sheets("Master").Range("a1").Value >= Sheets("Master").Range("c49").Value Then
Sheets("BZ_RTD").Select
Range("C1:C51,F1:G51").Select
Selection.Copy
Sheets("DataPaste").Select
Range("em1").Select
ActiveSheet.Paste
Range("em1").Select
End If
If Sheets("Master").Range("d50").Value > Sheets("Master").Range("a1").Value And Sheets("Master").Range("a1").Value >= Sheets("Master").Range("c50").Value Then
Sheets("BZ_RTD").Select
Range("C1:C51,F1:G51").Select
Selection.Copy
Sheets("DataPaste").Select
Range("ep1").Select
ActiveSheet.Paste
Range("ep1").Select
End If
If Sheets("Master").Range("d51").Value > Sheets("Master").Range("a1").Value And Sheets("Master").Range("a1").Value >= Sheets("Master").Range("c51").Value Then
Sheets("BZ_RTD").Select
Range("C1:C51,F1:G51").Select
Selection.Copy
Sheets("DataPaste").Select
Range("es1").Select
ActiveSheet.Paste
Range("es1").Select
End If
If Sheets("Master").Range("d52").Value > Sheets("Master").Range("a1").Value And Sheets("Master").Range("a1").Value >= Sheets("Master").Range("c52").Value Then
Sheets("BZ_RTD").Select
Range("C1:C51,F1:G51").Select
Selection.Copy
Sheets("DataPaste").Select
Range("ev1").Select
ActiveSheet.Paste
Range("ev1").Select
End If
If Sheets("Master").Range("d53").Value > Sheets("Master").Range("a1").Value And Sheets("Master").Range("a1").Value >= Sheets("Master").Range("c53").Value Then
Sheets("BZ_RTD").Select
Range("C1:C51,F1:G51").Select
Selection.Copy
Sheets("DataPaste").Select
Range("ey1").Select
ActiveSheet.Paste
Range("ey1").Select
End If
If Sheets("Master").Range("d54").Value > Sheets("Master").Range("a1").Value And Sheets("Master").Range("a1").Value >= Sheets("Master").Range("c54").Value Then
Sheets("BZ_RTD").Select
Range("C1:C51,F1:G51").Select
Selection.Copy
Sheets("DataPaste").Select
Range("fb1").Select
ActiveSheet.Paste
Range("fb1").Select
End If
End Sub
จากปัญหาดังกล่าวต้องการให้แสดงผลเป็นอย่างไร กรุณาแนบไฟล์ Excel ที่มี Code เรียบร้อยแล้วมาด้วยจะได้สะดวกในการตรวจสอบครับJarupong wrote:ขอบคุณ อ. ที่ชี้แนะวิธีโฟสต์ Code ครับ เรื่องการใช้งาน เจอปัญหาอยู่บ้างครับ คือเจอว่าหลังจาก copy ที่เวลาตามที่ตั้งใว้แล้ว แต่พอถึงรอบเวลาใหม่ คือ 5 นาทีถัดมา ข้อมูลที่คัดลอกใว้ก่อนหน้า มีการเปลี่ยนแปลงค่าไปตามข้อมูลที่เข้ามาใหม่ครับในแถวของcolumn C,D,E... ใน Sheet Deal,Vbuy, Vsell ครับ
Code: Select all
If Sheets("Master").Range("d2").Value > Sheets("Master").Range("a1").Value _
And Sheets("Master").Range("a1").Value >= Sheets("Master").Range("c2").Value Then
Sheets("BZ_RTD").Range("A1:A51,C1:C51,F1:G51").Copy Sheets("DataPaste").Range("A1")
Sheets("BZ_RTD").Range("A1:A51,C1:C51").Copy Sheets("Deal").Range("A1")
Sheets("BZ_RTD").Range("A1:A51,F1:F51").Copy Sheets("Vbuy").Range("A1")
Sheets("BZ_RTD").Range("A1:A51,G1:G51").Copy Sheets("Vsell").Range("A1")
End If
'...Other code