Monday, December 22, 2014

Copy With Destination Defined Makes Cleaner VBA Code

Following example code simplify the copy process by eliminating 4 line codes such as Range.copy, Sheet.Activate, Range.Select, and Activesheet.Paste.

    Range("B12:C17").Copy Destination:=Range("B30")

Even shorter:

    Range("B12:C17").Copy Range("B30")

Similarly, following code can be used for moving:

    Range("B12:C17").Cut Range("B30")

No comments: