Moving through tables on word with tab key

G

Guest

Hi :

Is there a way that I can change the way I move through tables in word by
pressing the tab key? when I am in a table and press tab, i move from the
left cell to the cell on the right, and when I get to the end of a row, I
then go to the leftmost cell in the next row. What I want to do is press the
tab key, and have the cursor move to the cell directly below it. When I get
to the end of a column and press the tab key, I want to move not to the
topmost cell on the next column, but to the second (which is the top most
nonheader cell on the table) cell on the next column. How can I do this?

Thanks in advance,


Steve-o
 
T

Tony Jollans

There is no way you can change the tab key's action but, in a table cell,
that is the "NextCell" command. You can override the NextCell command by
creating a macro called NextCell and in here you can do anything you want.

To code something which took account of all the possible variables would be
quite complex but the basic logic would be something like this

Sub NextCell()

If Selection.Cells.Count = 1 Then
r = Selection.Cells(1).RowIndex
c = Selection.Cells(1).ColumnIndex
If r = Selection.Tables(1).Rows.Count Then
If c = Selection.Tables(1).Columns.Count Then
MsgBox "Last cell. What do you want to do here?"
Else
r = 1
While Selection.Tables(1).Rows(r).HeadingFormat
r = r + 1
Wend
Selection.Tables(1).Cell(r, c + 1).Range.Select
End If
Else
Selection.Tables(1).Cell(r + 1, c).Range.Select
End If
Else
Selection.Cells(1).Range.Select
End If

End Sub
 

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