In the very first macro presented in this book, a recorded macro was used to move the contents of one cell to another:
Sub Macro1()
Range("A1").Select
Selection.Cut
Range("C1").Select
ActiveSheet.Paste
End Sub
Disadvantages of this approach:
- Multiple steps are required, increasing the chance of errors.
- It is unclear which workbook and worksheet the move operation applies to.
- The process runs more slowly.
Using direct referencing, you can perform this task more clearly and efficiently:
Sub MoveCells()
ThisWorkbook.Worksheets("Sheet1").Range("A7:A9").Cut _
Destination:=ThisWorkbook.Worksheets("Sheet1").Range("B7")
End Sub
This method clearly specifies the source and destination ranges within the same workbook and worksheet. It avoids unnecessary selection and pasting steps, resulting in faster and more reliable code.