Macros รัน ข้อมูลผิดไม่เหมือนตอน Record ครับ (มีตัวอย่างครับ)
Posted: Wed Jan 05, 2022 3:32 pm
Macros รัน ข้อมูลผิดไม่เหมือนตอน Record ครับ (มีตัวอย่างครับ)
เช่น ตอน Record ใส่ข้อมูล 5 เเถว
แต่พอ ด้วยมูลด้วย 5เเถว เหมือนเดิม ก็ถูกครับ แต่ พอเปลี่ยน เป็น 3 เเถว ก็ทำงานผิดแล้วครับ
Sub Macro12()
'
' Macro12 Macro
'
' Keyboard Shortcut: Ctrl+Shift+W
'
Range("A1").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Selection.End(xlDown).Select
Range("A6").Select
ActiveSheet.Paste
Selection.End(xlUp).Select
Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.Copy
Selection.End(xlDown).Select
Range("A11").Select
ActiveSheet.Paste
Selection.End(xlUp).Select
Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.Copy
Selection.End(xlDown).Select
Range("A21").Select
ActiveSheet.Paste
Selection.End(xlUp).Select
Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.Copy
Selection.End(xlDown).Select
Range("A41").Select
ActiveSheet.Paste
Selection.End(xlUp).Select
Range("B1").Select
Application.CutCopyMode = False
Range("A1").Select
End Sub
เช่น ตอน Record ใส่ข้อมูล 5 เเถว
แต่พอ ด้วยมูลด้วย 5เเถว เหมือนเดิม ก็ถูกครับ แต่ พอเปลี่ยน เป็น 3 เเถว ก็ทำงานผิดแล้วครับ
Sub Macro12()
'
' Macro12 Macro
'
' Keyboard Shortcut: Ctrl+Shift+W
'
Range("A1").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Selection.End(xlDown).Select
Range("A6").Select
ActiveSheet.Paste
Selection.End(xlUp).Select
Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.Copy
Selection.End(xlDown).Select
Range("A11").Select
ActiveSheet.Paste
Selection.End(xlUp).Select
Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.Copy
Selection.End(xlDown).Select
Range("A21").Select
ActiveSheet.Paste
Selection.End(xlUp).Select
Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.Copy
Selection.End(xlDown).Select
Range("A41").Select
ActiveSheet.Paste
Selection.End(xlUp).Select
Range("B1").Select
Application.CutCopyMode = False
Range("A1").Select
End Sub