Home |
Search |
Today's Posts |
|
#1
![]() |
|||
|
|||
![]()
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
![]() |
|||
|
|||
![]()
Robin,
Try: Sub ScratchMacro() Dim oTbl As Table For Each oTbl In ActiveDocument.Tables oTbl.Columns(2).Sort ExcludeHeader:=True Next End Sub |
#3
![]() |
|||
|
|||
![]()
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
![]() |
|||
|
|||
![]()
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 | |
|
|
![]() |
||||
Thread | Forum | |||
How do I get multiple Excel rows merged into Word document when .. | Mailmerge | |||
Adding multiple rows to a table in Word? | Microsoft Word Help | |||
How do I add multiple rows to a table? | Tables | |||
Excel Link: Adding rows in Excel does not add cells in Word | Tables | |||
Can Table AutoFormat apply formatting to multiple heading rows? | Tables |