Hi,
I found the following code that I am using to swap cells:
Code
Sub SwapSelections()
' Local Variables
Dim intROffset As Integer, intCOffset As Integer
Dim cell As Range
Dim varTemp As Variant
' Verify selection information
' There must be 2 areas
If Selection.Areas.Count <> 2 Then Exit Sub
' Both selections must be same size
If Selection.Areas(1).Rows.Count <> Selection.Areas(2).Rows.Count Then Exit Sub
If Selection.Areas(1).Columns.Count <> Selection.Areas(2).Columns.Count Then Exit Sub
' User has selected two identicaly sized areas
' Determine the offset in rows and columns from each areas A1 to the other
intROffset = Abs(Selection.Areas(1).Range("A1").Row - Selection.Areas(2).Range("A1").Row)
intCOffset = Abs(Selection.Areas(1).Range("A1").Column - Selection.Areas(2).Range("A1").Column)
' Swap cell values
For Each cell In Selection.Areas(1)
varTemp = cell
cell = cell.Offset(intROffset, intCOffset)
cell.Offset(intROffset, intCOffset) = varTemp
Next cell
End Sub
Display More
It works well with swapping ranges on the same worksheet.
Is there a way to modify the code so that it will be able to swap ranges on different worksheets?
Thanks,
Andy