cell value swapping
Private CommandButton1_Click()
dim v as variant
if Typename(Selection) < "Range" then exit sub
If selection.Count 2 or _
Selection.Count < 2 then Exit sub
if Areas.count = 1 then
v = selection(1)
selection(1) = selection(2)
selection(2) = v
else
v = selection.Areas(1).Value
selection.Areas(1).Value = _
selection.Areas(2).Value
selection.Areas(2).Value = v
end if
end if
End Sub
--
Regards,
Tom Ogilvy
"pj" wrote in message
...
I have a region of cells that need to meet certain
conditions to reach a goal. All the values of these cells
will remain the same within the region. However, depending
on the results of the conditions some of these values may
need to be swapped.
I would like to put a command button on the sheet such
that when two cells are selected (anywhere within the
region) then clicking the command button will find those
cells and swap the values in them.
Is this possible and how? TIA.
pj
|