How to select a series of cells in a table?

J

Jun

I have a multiple row and 2 column table. I would like to select a certain
number of cells that is in column 1. Say that I want to get rows 2 to 10 of
column 1, how would I go about doing that?

Thanks in advance.

Jun
 
D

DA

Hi Jun

There's a few different methods you can use.. here's one
of them to get you started. Check your VBA help on
extending and expanding selections to get some other
ideas.

---------------------
With ActiveDocument.Tables(1)
pos = .Cell(2, 1).Range.Start
posEnd = .Cell(10, 1).Range.End
Set myRange = ActiveDocument. _
Range(Start:=pos, End:=posEnd)
myRange.Select
End With
 
J

Jay Freedman

Hi DA,

I have to say I'm astonished that this bit of code works as intended. The
reason is that the range myRange includes not just the cells in column 1
from row 2 to row 10, but also the cells in column 2 from row 2 to row 9.
The range includes all the characters from the Start to the End, and Word
counts them from left to right across each row and then down to the next
row.

You can prove this by changing the example from myRange.Select to
myRange.Bold = True and watching the result.

There must be special code in Word's user interface to allow selecting cells
in a single column without picking up the cells in surrounding columns, and
the .Select method either invokes or simulates that code. So while your code
does answer Jun's question correctly, it could be misleading if you try to
apply it to any action except selection.
 
H

Helmut Weber

Hi Jay,
exactly! That is why I'm inclined to address each cell seperately,
if it comes to columns, as there is no column range.
Though sometimes seemingly simple solutions seem to work.
---
Greetings from Bavaria, Germany
Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word XP, Win 98
http://word.mvps.org/
 
J

Jun

Thank you. This works great. I greatly appreciate your help as well as
others whom responded (Jay, Helmut).

Jun
 
D

DA

Hi Guys

I agree with you. Was playing around with the range, so I
was surprised it actually worked myself, as it's not
normally the way I work with tables either.

Yet another odd-ball feature/bug about Word has been
uncovered :)

Dennis.
 

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