Mình đã ghi record code với các thao tác lặp giống nhau và được đoạn code như sau:
Sub CODE()
'
' CODE Macro
'
'
Range("A5").Select
Selection.Copy
ActiveSheet.Paste
Range("A6").Select
Application.CutCopyMode = False
Selection.Copy
ActiveSheet.Paste
Range("A8").Select
Application.CutCopyMode = False
Selection.Copy
ActiveSheet.Paste
Range("A9").Select
Application.CutCopyMode = False
Selection.Copy
ActiveSheet.Paste
Range("A11").Select
Application.CutCopyMode = False
Selection.Copy
ActiveSheet.Paste
Range("A12").Select
Application.CutCopyMode = False
Selection.Copy
ActiveSheet.Paste
Range("A14").Select
Application.CutCopyMode = False
Selection.Copy
ActiveSheet.Paste
Range("A15").Select
Application.CutCopyMode = False
Selection.Copy
ActiveSheet.Paste
Range("A17").Select
Application.CutCopyMode = False
Selection.Copy
ActiveSheet.Paste
Range("A18").Select
Application.CutCopyMode = False
Selection.Copy
ActiveSheet.Paste
Range("A20").Select
Application.CutCopyMode = False
Selection.Copy
ActiveSheet.Paste
Range("A21").Select
Application.CutCopyMode = False
End Sub
- Nay mong muốn được các bạn chỉ cách sửa đoạn code trên như thế nào để nó ngắn gọn đi ạ? Xin cảm ơn!
Sub CODE()
'
' CODE Macro
'
'
Range("A5").Select
Selection.Copy
ActiveSheet.Paste
Range("A6").Select
Application.CutCopyMode = False
Selection.Copy
ActiveSheet.Paste
Range("A8").Select
Application.CutCopyMode = False
Selection.Copy
ActiveSheet.Paste
Range("A9").Select
Application.CutCopyMode = False
Selection.Copy
ActiveSheet.Paste
Range("A11").Select
Application.CutCopyMode = False
Selection.Copy
ActiveSheet.Paste
Range("A12").Select
Application.CutCopyMode = False
Selection.Copy
ActiveSheet.Paste
Range("A14").Select
Application.CutCopyMode = False
Selection.Copy
ActiveSheet.Paste
Range("A15").Select
Application.CutCopyMode = False
Selection.Copy
ActiveSheet.Paste
Range("A17").Select
Application.CutCopyMode = False
Selection.Copy
ActiveSheet.Paste
Range("A18").Select
Application.CutCopyMode = False
Selection.Copy
ActiveSheet.Paste
Range("A20").Select
Application.CutCopyMode = False
Selection.Copy
ActiveSheet.Paste
Range("A21").Select
Application.CutCopyMode = False
End Sub
- Nay mong muốn được các bạn chỉ cách sửa đoạn code trên như thế nào để nó ngắn gọn đi ạ? Xin cảm ơn!