View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
helene and gabor helene and gabor is offline
external usenet poster
 
Posts: 58
Default Swap Two Values in one Command

Hello Mr. Rothstein,
Very nice solution. I usually enjoy your replies and wonder which forum you
are going to "migrate" to?
I am a bit disappointed in MS's phony instructions.

Best Regards,

Gabor Sebo


----- Original Message -----
From: "Rick Rothstein"
Newsgroups: microsoft.public.excel.programming
Sent: Sunday, May 30, 2010 12:21 AM
Subject: Swap Two Values in one Command


If Value1 and Value2 are numeric values, then you can swap them without
the need for an intermediate variable...

Value1 = Value1 + Value2
Value2 = Value1 - Value2
Value1 = Value1 - Value2

--
Rick (MVP - Excel)


"Dave Peterson" wrote in message
...
I think you'll need that intermediate variable.

sort wrote:

How to swap Two Values in one Command.

xxx=value1
value1=value2
value2=xxx


--

Dave Peterson



"Rick Rothstein" wrote in message
...
If Value1 and Value2 are numeric values, then you can swap them without
the need for an intermediate variable...

Value1 = Value1 + Value2
Value2 = Value1 - Value2
Value1 = Value1 - Value2

--
Rick (MVP - Excel)


"Dave Peterson" wrote in message
...
I think you'll need that intermediate variable.

sort wrote:

How to swap Two Values in one Command.

xxx=value1
value1=value2
value2=xxx


--

Dave Peterson