move to bottom of table

  • Thread starter Jesper Fjølner
  • Start date
J

Jesper Fjølner

I've created a table with VBA and I'm moving the cursor around in the cells.
Can I move the cursor to the last row of the table regardless of where the
cursor is in the table at that point?
Say I have a 10x10 table and the cursor is in row 4, column 4. Can I use the
...selection.movedown command to move the cursor directly to the last row?
(row 10, column 4)
Thanks for you help.
 
J

Jonathan West

Jesper Fjølner said:
I've created a table with VBA and I'm moving the cursor around in the
cells.
Can I move the cursor to the last row of the table regardless of where the
cursor is in the table at that point?
Say I have a 10x10 table and the cursor is in row 4, column 4. Can I use
the
..selection.movedown command to move the cursor directly to the last row?
(row 10, column 4)
Thanks for you help.

Hi Jesper

It can be done in one (very long) line of code. The following will move the
cursor to the start of the last row of the current table (copy and paste it
all onto a single line)

ActiveDocument.Range(Selection.Tables(1).Rows.Last.Range.Characters(1).Start,
Selection.Tables(1).Rows.Last.Range.Characters(1).Start).Select


If instead you want to move to the start of the last cell of the current
column, then you can do this (again, paste it all onto one line)

ActiveDocument.Range(Selection.Columns(1).Cells(Selection.Columns(1).Cells.Count).Range.Start,
Selection.Columns(1).Cells(Selection.Columns(1).Cells.Count).Range.Start).Select


--
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org
 
J

Jesper Fjølner

It can be done in one (very long) line of code. The following will move
the
cursor to the start of the last row of the current table (copy and paste it
all onto a single line)
ActiveDocument.Range(Selection.Tables(1).Rows.Last.Range.Characters(1).Start
,
Selection.Tables(1).Rows.Last.Range.Characters(1).Start).Select

Phew big one. I couldn't get this one to work, but it ended up working using
..MoveEnd (wdColumn) ?
Thanks though!
 

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