I am just trying to learn more about VBA.
Suppose I have a document (user form to be exact). In that form are some
tables (lets say 3). Each table has a different number of columns (but only
one row - more later). Each table has distinctly different fields in the
columns (some text input, some checkbox(es), and some drop down populated).
Idea is to have the table be dynamically grow ("Escaping" is still tricky).
However, each new, added row MUST have the exact item in each column just
above, i.e., add a row at the bottom and copy the fields from above (but text
fields are blank, drop down boxes populated like the previous row). Making
sense so far? (sometimes I do not make any sense).
My question is:
Can I figure out what the column above contains, then copy that item to the
cell below?
If you need an example to look at, I have a quick one I am experimenting with.
BTW, many thanks to Doug Robbins for his help getting me started (he may
have "created a monster" with me).
Thanks
F
Cindy M -WordMVP- - 07 Jul 2005 10:20 GMT
Hi =?Utf-8?B?RnJlZEVwNTc=?=,
> Suppose I have a document (user form to be exact). In that form are some
> tables (lets say 3). Each table has a different number of columns (but only
[quoted text clipped - 5 lines]
> fields are blank, drop down boxes populated like the previous row). Making
> sense so far? (sometimes I do not make any sense).
tbl.Rows(index).Range.Copy or loop through each cell and copy the cell range.
then paste in the target range.
However, my preference in a case such as this is to create an AutoText entry
from each type of row, and simply insert the AutoText entry as required.
Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org
This reply is posted in the Newsgroup; please post any follow question or reply
in the newsgroup and not by e-mail :-)
FredEp57 - 07 Jul 2005 14:46 GMT
Hmmmmm.... I am not very good at this VBA/Macro thing and am not sure what
you mean by the second statement. How do I create an AutoText entry like you
describe?
Also, I am not sure how to loop through the cells.
I am new to VBA/Macros so could use lots of help/direction. Any manuals,
books, websites, etc. for learning would be greatly appreciated.
Again thanks
F
> Hi =?Utf-8?B?RnJlZEVwNTc=?=,
>
[quoted text clipped - 22 lines]
> This reply is posted in the Newsgroup; please post any follow question or reply
> in the newsgroup and not by e-mail :-)
Michael Bednarek - 07 Jul 2005 11:10 GMT
On Tue, 5 Jul 2005 21:32:01 -0700, "FredEp57"
<FredEp57@discussions.microsoft.com> wrote in
microsoft.public.word.vba.general:
>I am just trying to learn more about VBA.
>
[quoted text clipped - 11 lines]
>Can I figure out what the column above contains, then copy that item to the
>cell below?
[snip]
Copying the last row in its entirety to a newly created row is trivial:
With Selection.Tables(1)
.Rows(.Rows.Count).Range.Copy
.Rows(.Rows.Count).Range.Paste
End With
The part I couldn't figure out is how to omit, or delete after the copy,
the textual content of the copied range.

Signature
Michael Bednarek http://mbednarek.com/ "POST NO BILLS"