A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Word » Tables
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

alphanumerical sorting in a word table



 
 
Thread Tools Display Modes
  #1  
Old February 7th, 2006, 05:10 PM posted to microsoft.public.word.tables
external usenet poster
 
Posts: n/a
Default alphanumerical sorting in a word table

I'm trying to sort the following document in alphanumercal order going top to
bottom in alpha order from column A, B C... when i sort it is reading left to
right



  #2  
Old February 7th, 2006, 07:29 PM posted to microsoft.public.word.tables
external usenet poster
 
Posts: n/a
Default alphanumerical sorting in a word table

If you are using non-table Columns, it should sort properly. But if you have
three columns in a Table, it will not. You would have to move columns B and
C to below the end of Column A before you could make a proper sort. After
doing so, you could replace them in B and C.

"Tracylyn" wrote in message
...
I'm trying to sort the following document in alphanumercal order going top
to
bottom in alpha order from column A, B C... when i sort it is reading left
to
right




  #3  
Old February 7th, 2006, 07:40 PM posted to microsoft.public.word.tables
external usenet poster
 
Posts: n/a
Default alphanumerical sorting in a word table

Let me try it....

"Richard O. Neville" wrote:

If you are using non-table Columns, it should sort properly. But if you have
three columns in a Table, it will not. You would have to move columns B and
C to below the end of Column A before you could make a proper sort. After
doing so, you could replace them in B and C.

"Tracylyn" wrote in message
...
I'm trying to sort the following document in alphanumercal order going top
to
bottom in alpha order from column A, B C... when i sort it is reading left
to
right





  #4  
Old February 7th, 2006, 11:19 PM posted to microsoft.public.word.tables
external usenet poster
 
Posts: n/a
Default alphanumerical sorting in a word table

Select the table you want sorted and try running this macro:

Option Explicit
Sub UpDownTableSort()
Dim i As Long
Dim j As Long
Dim k As Long
Dim oCell As Cell
Dim oTmpTable As Table
Dim oRng As Word.Range
i = Selection.Tables(1).Range.Cells.Count
'Insert a temporary 1 column/multi-row table at the end of the document
With ActiveDocument.Paragraphs.Last
.Range.Paragraphs.Add
.Range.Tables.Add .Range, i, 1
End With
'Define this table
Set oTmpTable = ActiveDocument.Tables(ActiveDocument.Range.Tables. Count)
'Fill oTmpTable with contents of table to be sorted
For Each oCell In Selection.Tables(1).Range.Cells
With oTmpTable
.Cell(i, 1).Range.Text = Left(oCell.Range.Text, Len(oCell.Range.Text) -
2)
End With
i = i - 1
Next
'Sort
oTmpTable.Sort
'Redefine selected table contents based on sort
With Selection.Tables(1)
For i = 1 To .Range.Columns.Count
For j = 1 To .Range.Rows.Count
k = k + 1
Set oRng = oTmpTable.Cell(k, 1).Range
.Cell(j, i).Range.Text = Left(oRng.Text, Len(oRng.Text) - 2)
Next j
Next i
End With
'Clean up.
oTmpTable.Delete
Set oRng = Nothing
Set oTmpTable = Nothing
End Sub

--
Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.


Tracylyn wrote:
I'm trying to sort the following document in alphanumercal order
going top to bottom in alpha order from column A, B C... when i sort
it is reading left to right



  #5  
Old February 8th, 2006, 08:09 PM posted to microsoft.public.word.tables
external usenet poster
 
Posts: n/a
Default alphanumerical sorting in a word table

Thanks, but how to you run a macro

"Greg Maxey" wrote:

Select the table you want sorted and try running this macro:

Option Explicit
Sub UpDownTableSort()
Dim i As Long
Dim j As Long
Dim k As Long
Dim oCell As Cell
Dim oTmpTable As Table
Dim oRng As Word.Range
i = Selection.Tables(1).Range.Cells.Count
'Insert a temporary 1 column/multi-row table at the end of the document
With ActiveDocument.Paragraphs.Last
.Range.Paragraphs.Add
.Range.Tables.Add .Range, i, 1
End With
'Define this table
Set oTmpTable = ActiveDocument.Tables(ActiveDocument.Range.Tables. Count)
'Fill oTmpTable with contents of table to be sorted
For Each oCell In Selection.Tables(1).Range.Cells
With oTmpTable
.Cell(i, 1).Range.Text = Left(oCell.Range.Text, Len(oCell.Range.Text) -
2)
End With
i = i - 1
Next
'Sort
oTmpTable.Sort
'Redefine selected table contents based on sort
With Selection.Tables(1)
For i = 1 To .Range.Columns.Count
For j = 1 To .Range.Rows.Count
k = k + 1
Set oRng = oTmpTable.Cell(k, 1).Range
.Cell(j, i).Range.Text = Left(oRng.Text, Len(oRng.Text) - 2)
Next j
Next i
End With
'Clean up.
oTmpTable.Delete
Set oRng = Nothing
Set oTmpTable = Nothing
End Sub

--
Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.


Tracylyn wrote:
I'm trying to sort the following document in alphanumercal order
going top to bottom in alpha order from column A, B C... when i sort
it is reading left to right




  #6  
Old February 8th, 2006, 09:02 PM posted to microsoft.public.word.tables
external usenet poster
 
Posts: n/a
Default alphanumerical sorting in a word table

See http://www.gmayor.com/installing_macro.htm

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
Word MVP FAQ site: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.

"Tracylyn" wrote in message
...
Thanks, but how to you run a macro

"Greg Maxey" wrote:

Select the table you want sorted and try running this macro:

Option Explicit
Sub UpDownTableSort()
Dim i As Long
Dim j As Long
Dim k As Long
Dim oCell As Cell
Dim oTmpTable As Table
Dim oRng As Word.Range
i = Selection.Tables(1).Range.Cells.Count
'Insert a temporary 1 column/multi-row table at the end of the document
With ActiveDocument.Paragraphs.Last
.Range.Paragraphs.Add
.Range.Tables.Add .Range, i, 1
End With
'Define this table
Set oTmpTable = ActiveDocument.Tables(ActiveDocument.Range.Tables. Count)
'Fill oTmpTable with contents of table to be sorted
For Each oCell In Selection.Tables(1).Range.Cells
With oTmpTable
.Cell(i, 1).Range.Text = Left(oCell.Range.Text,

Len(oCell.Range.Text) -
2)
End With
i = i - 1
Next
'Sort
oTmpTable.Sort
'Redefine selected table contents based on sort
With Selection.Tables(1)
For i = 1 To .Range.Columns.Count
For j = 1 To .Range.Rows.Count
k = k + 1
Set oRng = oTmpTable.Cell(k, 1).Range
.Cell(j, i).Range.Text = Left(oRng.Text, Len(oRng.Text) - 2)
Next j
Next i
End With
'Clean up.
oTmpTable.Delete
Set oRng = Nothing
Set oTmpTable = Nothing
End Sub

--
Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.


Tracylyn wrote:
I'm trying to sort the following document in alphanumercal order
going top to bottom in alpha order from column A, B C... when i sort
it is reading left to right





 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Need to Improve Code Copying/Pasting Between Workbooks David General Discussion 1 January 6th, 2006 03:56 AM
word and wordperfect mail merges slgcms Mailmerge 2 September 27th, 2005 02:13 PM
How to change merge forms from Word Perfect to Microsoft Word Charles Kenyon General Discussion 1 December 30th, 2004 03:35 PM
Here's a shocker Mike Labosh General Discussion 2 October 26th, 2004 05:04 PM
Word 2000/2002 - Proper Mail Merge steps for ODBC? Tony_VBACoder Mailmerge 7 September 2nd, 2004 09:21 PM


All times are GMT +1. The time now is 02:17 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.