How to interchange the values between two selected cells?

  • Thread starter Thread starter Ramesh
  • Start date Start date
R

Ramesh

I would like to know if there is any function in excel which will enable the
users to interchange the values between two selected cells.

Ramesh
 
Hi Ramesh

You will have to use a macro to do this. Try the below. If you are new to
macros set the Security level to low/medium in (Tools|Macro|Security). From
workbook launch VBE using short-key Alt+F11. From menu 'Insert' a module and
paste the below code. Save. Get back to Workbook.

Select the 2 similar areas/cells to be swapped. Run macro from
Tools|Macro|Run <selected macro()>

Sub SwapCells()
Dim varTemp1 As Variant, varTemp2 As Variant
varTemp1 = Selection.Areas(1)
varTemp2 = Selection.Areas(2)
Selection.Areas(1) = varTemp2
Selection.Areas(2) = varTemp1
End Sub

If this post helps click Yes
 
Back
Top