moving down columns in tables a row at a time

D

De Vo

Hi

I wonder if i people can advise me on the best way of doing the
following.

I am studying writing VBA in Word with various tables at the moment and
I wish to the following. please can people offer their techniques on
doing this, or should it be done with more coding of less efficient
variety.

Scenario

I have multiple tables which I wish to be able to select a start
position of (row and column) moving through the table to the end.

i can see a multiple loop which I presume I could make in to a function
to basically have it go to the start position and then just keep moving
down a row at a time or what other varients i need to do.

I am still a bit new on the vba command I would use to do the moving of
the row and column function

so you can please suggest the best command to use.

many thanks

de vo
 
D

Dave Lett

Hi De Vo

Here's some code to get you jump started

Dim oRngRow As Rang
Set oRngRow = ActiveDocument.Range
(Start:=Selection.Tables(1).Range.Start,
End:=Selection.Rows(1).Range.End

If oRngRow.Rows.Count <> Selection.Tables(1).Rows.Count The
Selection.Tables(1).Rows(oRngRow.Rows.Count + 1).Range.Selec
End I

HTH
Dave
 
D

De Vo

Hi Dave

Thanks very much for the code.. that will get me started...

Btw if i need to use a bookmark as the table refer can i just change
the index number to the bookmark name ?

Once again many thanks for your help

regards

De Vo
 
D

Dave Lett

Hi De Vo

"Btw if i need to use a bookmark as the table refer can i just chang
the index number to the bookmark name ?

Do you mean the index number for the table, as in the following
Set oRngRow = ActiveDocument.Range
(Start:=Selection.Tables(1).Range.Start,
End:=Selection.Rows(1).Range.End

If so, then no, you cannot simply substitute the name of the bookmark. You will need to rewrite the Set statement to something like the following
Set oRngRow = ActiveDocument.Range
(Start:=ActiveDocument.Bookmarks("Test").Range.Tables(1).Range.Start,
End:=ActiveDocument.Bookmarks("Test").Range.Tables(1).Range.End

If the bookmark encompasses the table and only the table, then you can use something like the following
Set oRng = ActiveDocument.Bookmarks("Test").Rang

HTH
Dav
 

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