Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.tables
[email protected] christianlott1@yahoo.com is offline
external usenet poster
 
Posts: 2
Default vba code to select across relative

In a table where I have a cell selected I want to select the cell to
the right of it, including the start cell. In the end I need to have
both cells selected at the same time using the start cell as the
source position.

Why?

It's a pivot table. The start cell has a multiple of cells to the
right of it. I need to select that source cell (easy) and the 1-n
cells to the right of that start cell.

ie the start cell takes up one large cell over four rows, to it's
right are four smaller cells.


Thanks,


Christian

  #2   Report Post  
Posted to microsoft.public.word.tables
Lene Fredborg Lene Fredborg is offline
external usenet poster
 
Posts: 1,291
Default vba code to select across relative

The following code lines may do what you want:

With Selection
'Include the first cell to the right in the selection
.MoveRight unit:=wdCharacter, Count:=2, Extend:=wdExtend
'Extend selection to include the 3 cells below
.MoveDown unit:=wdLine, Count:=3, Extend:=wdExtend
End With

The code will only result in the correct selection under the conditions you
described, i.e. you select (or just click in) a single cell and the height of
that cell spans 4 cells to the right.

--
Regards
Lene Fredborg
DocTools - Denmark
www.thedoctools.com
Document automation - add-ins, macros and templates for Microsoft Word


" wrote:

In a table where I have a cell selected I want to select the cell to
the right of it, including the start cell. In the end I need to have
both cells selected at the same time using the start cell as the
source position.

Why?

It's a pivot table. The start cell has a multiple of cells to the
right of it. I need to select that source cell (easy) and the 1-n
cells to the right of that start cell.

ie the start cell takes up one large cell over four rows, to it's
right are four smaller cells.


Thanks,


Christian


  #3   Report Post  
Posted to microsoft.public.word.tables
[email protected] christianlott1@yahoo.com is offline
external usenet poster
 
Posts: 2
Default vba code to select across relative

On Jul 16, 3:34 pm, Lene Fredborg
wrote:
The following code lines may do what you want:

With Selection
'Include the first cell to the right in the selection
.MoveRight unit:=wdCharacter, Count:=2, Extend:=wdExtend
'Extend selection to include the 3 cells below
.MoveDown unit:=wdLine, Count:=3, Extend:=wdExtend
End With

The code will only result in the correct selection under the conditions you
described, i.e. you select (or just click in) a single cell and the height of
that cell spans 4 cells to the right.


Hey,

Thanks for the response. I had seen those functions (moveright and
movedown) but like you said, I'd need to know the number of cells each
time. For a table with variable numbers of cells, I'd need to have the
number of cells each handy (which I don't).

In this situation I had a pivot table from Access I copied over to
word then wanted to do some conditional formatting on it.

The easier solution was to have a copy of the column I needed to cue
off (the one side of the one to many) positioned on the many side as
well (now showing redundant values per line). This allowed me to
format row per row as needed, then after I just deleted that column
from the table.

Looks very nice

Christian

Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I see a text code, such as the code for 'line return'? Blackhawk Microsoft Word Help 3 January 26th 06 09:15 PM
Hyperlink - relative Man Utd New Users 2 December 15th 05 07:37 AM
Microworks asks for a code tahat I do not know. How do I get code Francisco Microsoft Word Help 1 November 23rd 05 09:01 PM
How do I turn select text on and use Find to select a block of te. hpmted Microsoft Word Help 2 April 13th 05 12:32 AM
Add code to select email field in mailmerge! Hans Mailmerge 4 February 3rd 05 06:47 AM


All times are GMT +1. The time now is 01:38 PM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"