ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   How to interchange the values between two selected cells? (https://www.excelbanter.com/excel-discussion-misc-queries/236436-how-interchange-values-between-two-selected-cells.html)

Ramesh

How to interchange the values between two selected cells?
 
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

Jacob Skaria

How to interchange the values between two selected cells?
 
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
---------------
Jacob Skaria


"Ramesh" wrote:

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



All times are GMT +1. The time now is 08:33 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com