View Full Version : Cell swapping
ukmxer
09-19-2007, 12:30 PM
Could anyone tell me how to click on a cell and then click on another cell and swap them over.
e.g click cell C4 store its contents then click cell c7 and move its contents to c4 and then move the stored c4 into c7.
thank you.
Bob Phillips
09-19-2007, 12:38 PM
This works by double-clicking the cells to swap
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Static prevCell As Range
Dim tmp As Variant
If prevCell Is Nothing Then
Set prevCell = Target
Else
tmp = Target.Value
Target.Value = prevCell.Value
prevCell.Value = tmp
Set prevCell = Nothing
End If
End Sub
ukmxer
09-19-2007, 03:13 PM
Thanks XLD, that worked a treat!
mdmackillop
09-20-2007, 12:26 AM
You can mark your thread "solved" using the Thread Tools dropdown
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.