Reply
 
Thread Tools Display Modes
  #1   Report Post  
\jeremy via OfficeKB.com\
 
Posts: n/a
Default exchange contents of 2 cells

If i have 2 cells (or groups of cells) is there a way to exchange the
contents or do I have to copy/paste the first contents into empty cell, then
copy/paste second contents into first cell, etc, etc....

Thanks.

Jeremy

--
Message posted via http://www.officekb.com
  #2   Report Post  
Doug Robbins
 
Posts: n/a
Default

If it's two whole columns that you have to interchange, select the second
one, then use Cut and the Select the first one and use Paste Columns.

If its just one cell, if you run the following code when the selection is in
the lefthand cell, it will make the substitution

Dim A As Range, B As Range, i As Long, j As Long, Atext As String
i = Selection.Information(wdEndOfRangeRowNumber)
j = Selection.Information(wdEndOfRangeColumnNumber)
Set A = Selection.Cells(1).Range
A.End = A.End - 1
Atext = A.Text
Set B = Selection.Tables(1).Cell(i, j + 1).Range
B.End = B.End - 1
Selection.Cells(1).Range = B.Text
Selection.Tables(1).Cell(i, j + 1).Range.Text = Atext


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
""jeremy via OfficeKB.com"" wrote in message
...
If i have 2 cells (or groups of cells) is there a way to exchange the
contents or do I have to copy/paste the first contents into empty cell,
then
copy/paste second contents into first cell, etc, etc....

Thanks.

Jeremy

--
Message posted via http://www.officekb.com



  #3   Report Post  
sf
 
Posts: n/a
Default

On Wed, 6 Jul 2005 21:03:18 +0200, Doug Robbins wrote:

If it's two whole columns that you have to interchange, select the second
one, then use Cut and the Select the first one and use Paste Columns.

If its just one cell, if you run the following code when the selection is in
the lefthand cell, it will make the substitution

Dim A As Range, B As Range, i As Long, j As Long, Atext As String
i = Selection.Information(wdEndOfRangeRowNumber)
j = Selection.Information(wdEndOfRangeColumnNumber)
Set A = Selection.Cells(1).Range
A.End = A.End - 1
Atext = A.Text
Set B = Selection.Tables(1).Cell(i, j + 1).Range
B.End = B.End - 1
Selection.Cells(1).Range = B.Text
Selection.Tables(1).Cell(i, j + 1).Range.Text = Atext


Holy mackeral! I'd drag and drop.
  #4   Report Post  
Doug Robbins
 
Posts: n/a
Default

There's more ways than one to skin a cat.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
"sf" wrote in message
...
On Wed, 6 Jul 2005 21:03:18 +0200, Doug Robbins wrote:

If it's two whole columns that you have to interchange, select the
second
one, then use Cut and the Select the first one and use Paste Columns.

If its just one cell, if you run the following code when the selection
is in
the lefthand cell, it will make the substitution

Dim A As Range, B As Range, i As Long, j As Long, Atext As String
i = Selection.Information(wdEndOfRangeRowNumber)
j = Selection.Information(wdEndOfRangeColumnNumber)
Set A = Selection.Cells(1).Range
A.End = A.End - 1
Atext = A.Text
Set B = Selection.Tables(1).Cell(i, j + 1).Range
B.End = B.End - 1
Selection.Cells(1).Range = B.Text
Selection.Tables(1).Cell(i, j + 1).Range.Text = Atext


Holy mackeral! I'd drag and drop.



Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
developing multiple table of contents Chad Microsoft Word Help 1 June 22nd 05 04:40 AM
How do I set up a table of contents and chapter contents? Louis Garrett Microsoft Word Help 1 May 19th 05 05:06 PM
Item in Table of Contents throw off numbering Robert McN Page Layout 4 January 27th 05 12:50 AM
table of contents in thesis SSL New Users 1 January 9th 05 10:56 PM
Row Breaks w/Merged Cells Redglide90 Tables 1 December 22nd 04 08:03 PM


All times are GMT +1. The time now is 03:23 AM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"