Swapping Data
Overview
You can swap the contents of two cells or two blocks of cells.
When you swap data from a cell or a range of cells to another cell or range of cells, the settings for the cell are swapped along with the data. If you provided settings for the column or the row containing the cell, or the sheet, but not the cell itself, those settings are not swapped, unless you use the SwapColRange or SwapRowRange method. For example, if you have set the source cell's background color to red, the background color is swapped and the target cell will have a red background. However, if you have set the background color of the column containing the source cell to red, that setting is not swapped. For more information, see Formatted and Unformatted Data and Sheet Element Selection.
When you swap data from one cell to another, the data in one cell becomes the data in the other cell, and vice versa. For example, if cell A1 contains the value 4 and cell B3 contains the value 6 and you swap the values of the cells, the value of cell A1 becomes 6 and the value of cell B3 becomes 4.
If you attempt to swap a block that is larger than the available block at the destination, the swap operation is not performed. For example, if you attempt to swap a block of four cells and specify the destination as a cell at the edge of the sheet, the swap does not take place.
If the swap operation swaps overlapping blocks of cells, individual cells are swapped starting at the overlapping corner. As shown in the following figures, this method maintains the sheet's data.
When you swap blocks of data, you can specify whether formulas are adjusted. For more information, see Automatically Recalculating and Updating Formulas.