swap

G

Gary

I want to swap values of two cells. can anyone help me on that? Eg. Cell A1
contains the value 20 & cell A2 contains the value 100. I want 100 on A1 &
20 on A2.

Thanks
Gary
 
D

Desert Piranha

Gary said:
I want to swap values of two cells. can anyone help me on that? Eg. Cell
A1
contains the value 20 & cell A2 contains the value 100. I want 100 on
A1 &
20 on A2.

Thanks
GaryHi Gary,

Something on the order of this work?
Of course change tye ranges.


Code:
--------------------
Sub SwapCells()
Dim x As Integer
x = Range("a5").Value
Range("a5").Value = Range("a6").Value
Range("a6").Value = x
End Sub
 
G

Gary

Thanks a ton Desert. Its working fine. How do i add more ranges..can i just
write x=range("a5:a2000") ?

"Desert Piranha"
 
D

Desert Piranha

Gary said:
Thanks a ton Desert. Its working fine. How do i add more ranges..can
just
write x=range("a5:a2000") ?Hi Gary,

Are you looking for columns?

Like swap Column A and Column B.

Sub SwapCells()
Dim x As Integer ' Use this line for numbers or
' Dim x ' Use this line for text and numbers
x = Range("a5:a2000").Value
Range("a5:a2000").Value = Range("b5:b2000").Value
Range("b5:b2000").Value = x
End Su
 
B

Biff

Hi!

Try this:

=OFFSET(A1,1*IF(MOD(ROWS($1:1),2),1,-1),,)

Copy down as needed.

After you get everything flipped you can convert the formulas to constants
by:

Selecting the range of formulas
Goto Edit>Copy
Then, Edit>Paste Special>Values>OK

Then, you can delete the original data if desired.

Biff
 
J

JMB

And exactly where in your original post did you state that you had 5000
cells, pray tell.
 
Top