# Solved: Word VBA: Moving to next row in table



## JonWat (Nov 20, 2008)

I have a table with fixed text in to which I want to put variable text. My problem is moving reliably from one row to the next so the variable text ends up in the right place.

The MoveDown will move down only a line of text if a cell has multiple lines. If you select the cell before doing the move down, this mostly moves you to the next row, but still gets confused on rows that split across pages.

I figured that if you find the current row, you could just add 1 to it and then select the next row.

You can get the current row using 

Selection.Information(wdStartOfRangeRowNumber)

and you could select the row with

ActiveDocument.Tables(x).Rows(local_row +1).Select

but how do I know which table I'm in (or alternatively what do I do to get the Rows.Select to operate on the current table)?

Thanks,

JonWat


----------



## Anne Troy (Feb 14, 1999)

I've renamed your question, Jon, so that we'll all know you mean Word, and it'll require VBA.


----------



## JonWat (Nov 20, 2008)

If Selection.Information(wdWithInTable) = True Then
Selection.Rows(1).Next.Select
Selection.Cells(1).Select
End If

does what I need ( I think) -- selects the first column of the next row. Got nowhere trying to get the table using the Parent property of the Rows Collection (or anything else for that matter).

I'm still not sure I understand why it works quite like it does. I guess Rows(1) gives you the first row of what you have selected (or the row your cursor is on if you don't have a selection), then Next is a property of that Row that gives you the next one in the collection it belongs to. If that was right, I don;t really see why Selection.Row.Next.Select wouldn't work, but it doesn't.

Probably shows I've never programmed in VB.:up:


----------



## Anne Troy (Feb 14, 1999)

You wouldn't know it by me. I created www.vbaexpress.com 'cause I never wanted to have to learn.


----------

