How to interchange the values between two selected cells?

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
 
J

Jacob Skaria

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top