Reply
 
Thread Tools Display Modes
  #1   Report Post  
RFJ
 
Posts: n/a
Default Sorting cells within multiple rows

I need to sort the cell contents of column 2 of a set of tables (excluding
the header row). Tables have a variable number of rows (four to ten).

The sort sequence is alpha within each cell.

Each cell has a variable number of lines, each line is alphabetic.

Is there a way I can automate it to at least table level since having to do
each cell in turn (where the cells are updated weekly) is a real chore


TIA

Robin


  #2   Report Post  
Greg
 
Posts: n/a
Default

Robin,

Try:
Sub ScratchMacro()
Dim oTbl As Table
For Each oTbl In ActiveDocument.Tables
oTbl.Columns(2).Sort ExcludeHeader:=True
Next
End Sub

  #3   Report Post  
RFJ
 
Posts: n/a
Default

Greg,

Thanks for the suggestion - part way there. It seems to sort all the cells
in the second column as one long list. I need to alpha-sort the entries
within each cell.

Is that an easy adjustment (writing macro code I'm afraid is not something
I've accomplished with any success).




"Greg" wrote in message
oups.com...
Robin,

Try:
Sub ScratchMacro()
Dim oTbl As Table
For Each oTbl In ActiveDocument.Tables
oTbl.Columns(2).Sort ExcludeHeader:=True
Next
End Sub



  #4   Report Post  
Greg
 
Posts: n/a
Default

Robin,

I didn't have time to test extensively, but try:

Sub ScratchMacro()
Dim oTbl As Table
Dim oCell As Cell
For Each oTbl In ActiveDocument.Tables
oTbl.Columns(2).Sort ExcludeHeader:=True
For Each oCell In oTbl.Columns(2).Cells
oCell.Range.Select
Selection.MoveLeft Unit:=wdWord, Count:=1, Extend:=wdExtend
On Error Resume Next
Selection.Sort
On Error GoTo 0
Next
Next
End Sub

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 do I get multiple Excel rows merged into Word document when .. sebmailmerge Mailmerge 2 April 20th 05 03:47 PM
Adding multiple rows to a table in Word? Iron Mt Library Guy Microsoft Word Help 3 February 5th 05 12:08 AM
How do I add multiple rows to a table? Adding rows to tables Tables 3 January 29th 05 08:26 PM
Excel Link: Adding rows in Excel does not add cells in Word Jameslp Tables 2 December 9th 04 07:18 PM
Can Table AutoFormat apply formatting to multiple heading rows? aubreyco Tables 1 November 10th 04 05:02 PM


All times are GMT +1. The time now is 12:49 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"