SWAP 2 CELL'S CONTENTS IN MS EXCEL BY USING METHOD AS FOLLOWED:
USE FOLLOWING METHOD
1- Copy paste this VBA code into your Excel VBA editor as a module.
2- Save and come out of VBA
3- Under Developer go to macros
4- Assign the keyboard shortcut
USE FOLLOWING CODE:
Sub Swap2Values()
Dim Value1 As Range, Value2 As Range
Dim TempValue1 As String, TempValue2 As String
If Selection.Cells.Count > 2 Or Selection.Cells.Count < 2 Then
MsgBox "Please select only 2 cells. For other options check back soon!"
End
End If
If Selection.Areas.Count > 1 Then
Set Value1 = Selection.Areas(1).Cells(1, 1)
Set Value2 = Selection.Areas(2).Cells(1, 1)
ElseIf Selection.Rows.Count > Selection.Columns.Count Then
Set Value1 = Selection.Range("A1")
Set Value2 = Selection.Range("A2")
Else
Set Value1 = Selection.Range("A1")
Set Value2 = Selection.Range("B1")
End If
TempValue1 = Value1
TempValue2 = Value2
Value1 = TempValue2
Value2 = TempValue1
End Sub
-------------------------------------------------------------------------
Watch Video Here
No comments:
Write comments