Tables and references

F

FredEp57

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
 
C

Cindy M -WordMVP-

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
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).
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 :)
 
M

Michael Bednarek

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?
[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.
 
F

FredEp57

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
 

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