Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2
Default How do I exchange cell contents between two non-adjacent cells?

There must be a way to simply switch the contents of two Excel cells, what is
it?
answers to will be greatly appreciated.
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,819
Default How do I exchange cell contents between two non-adjacent cells?

Not natively.

dave parta wrote:

There must be a way to simply switch the contents of two Excel cells, what is
it?
answers to will be greatly appreciated.


  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,501
Default How do I exchange cell contents between two non-adjacent cells?

Hi,

It depeends on your definition od simple. Alt +F11 to open VB editor. Right
click 'This Workbook' and insert module and paste the code below in.

Select you 2 cells then run the code

Sub SwapEm()
Dim Firstvalue(), FirstValueAddress()
a = 1
ReDim Firstvalue(2), FirstValueAddress(2)
For Each c In Selection
Firstvalue(a) = c.Value
FirstValueAddress(a) = c.Address
a = a + 1
Next c
Range(FirstValueAddress(1)).Select
ActiveCell = Firstvalue(2)
Range(FirstValueAddress(2)).Select
ActiveCell = Firstvalue(1)
End Sub

Mike

"dave parta" wrote:

There must be a way to simply switch the contents of two Excel cells, what is
it?
answers to will be greatly appreciated.

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22,906
Default How do I exchange cell contents between two non-adjacent cells?

Here is some code from Gary's Student

Sub swap_um()
Dim v0 As Variant
Dim v1 As Variant
Dim s(2) As String
If Selection.Count < 2 Then Exit Sub
i = 0
For Each rr In Selection
s(i) = rr.Address
i = i + 1
Next
v0 = Range(s(0)).Value
v1 = Range(s(1)).Value
Range(s(1)).Value = v0
Range(s(0)).Value = v1
End Sub

Select any two cells...........adjacent or non-adjacentt.

Run macro.


Gord Dibben MS Excel MVP

On Fri, 12 Dec 2008 10:17:01 -0800, dave parta
wrote:

There must be a way to simply switch the contents of two Excel cells, what is
it?
answers to will be greatly appreciated.


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
sum cells based on contents of adjacent cell (validated list)? Casi12 Excel Worksheet Functions 3 April 29th 08 02:31 PM
Clear Contents of Adjacent Cell on Conditional Basis DoooWhat Excel Discussion (Misc queries) 8 March 7th 07 02:38 PM
Displaying contents of adjacent cells. MikeyB Excel Discussion (Misc queries) 7 July 29th 05 03:56 PM
Contents of adjacent cell from a function Nick Excel Worksheet Functions 5 July 8th 05 04:28 PM
exchange contents of cells \jeremy via OfficeKB.com\ New Users to Excel 6 July 8th 05 03:14 AM


All times are GMT +1. The time now is 03:17 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"