Moving Cells


Cutting and Pasting ranges of cells

You can cut and paste a single value using either of the following lines of code:

Range("A2").Cut Destination:=Range("D2") 
Range("A2").Cut Range("D2")

The Cut method also has an optional destination argument.
It is possible to cut and paste a range of cells:

Range("A2:B4").Select 
Selection.Cut
Range("D7").Select
ActiveSheet.Paste

Alternatively you can combine this to a single line.
This is possible because the Cut method can take an optional argument that can represent the range to be cut to. The next two lines are equivalent.

Range("A2:B4").Cut Destination:=Range("D7") 
Range("A2:B4").Cut Range("D7")

Application.Calculate

If you are manipulating a lot of cells then it is sometimes a good idea to switch the automatic calculation off temporarily

Application.Calculate = xlCalculation.xlCalculationManual 
'manipulating a lot of cells
Application.Calculate = xlCalculation.xlCalculationAutomatic

© 2024 Better Solutions Limited. All Rights Reserved. © 2024 Better Solutions Limited TopPrevNext