Copy text automatically from one cell in a table to another one

J

Jo Gjessing

Hi all,

In a Word document of mine I have three tables with two cells in each. When
the user writes something in the left cell of the uppermost table I want a
VBA script, or another function, to copy the text to the left cell of the
lowermost table. Can you imagine how I do this? If you have an enlightening
comment for me, please let me know. Thank you very much in advance.

Jo
 
J

Jo Gjessing

Hi all,

I forgot to write that we are using Word 2003 ...

Jo

Jo Gjessing skrev:
 
G

Graham Mayor

The following macro will copy the first cell of table 1 to the first cell of
table 3

Sub DuplicateCell1()
Dim oRng As Range
With ActiveDocument
Set oRng = .Tables(1).Cell(1, 1).Range
oRng.End = oRng.End - 1
.Tables(3).Cell(1, 1).Range.Text = oRng
End With
End Sub

http://www.gmayor.com/installing_macro.htm
--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
J

Jo Gjessing

Hi, Graham.

Thank you for responding so quickly.

I've now inserted another table in my document so I changed

..Tables(3).Cell(1, 1).Range.Text = oRng

to

..Tables(4).Cell(1, 1).Range.Text = oRng

Also I renamed your script from Sub DuplicateCell1() to Sub
DuplicateCell1_BeforePrint () to connect it to the BeforePrint event. I'm not
able, however, to make it work. Can that be because I now have two macros
connected to the BeforePrint in the same document? Hoping to hearing from you
again.

Jo

Jo Gjessing skrev:
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top