|
|
| Next: How to get a special character in my document? |
| Author |
Message |
Tiffany External

Since: Feb 07, 2005 Posts: 10
|
Posted: Wed Dec 28, 2005 11:21 am Post subject: Sorting Text In Table Archived from groups: microsoft>public>word>tables (more info?) |
|
|
I have a table that has 3 columns and about 10 rows. I am trying to sort the
text in the boxes so they are in alphabetical order. My problem is that when
I push sort it will only sort by column, and not by row. For example, say the
first couple of rows look like this:
Bear Ape Cat
Ant Crow Bug
Then when I push sort it sorts the columns into alphabetical order but not
the rows, and it shows up like this:
Ant Ape Bug
Bear Crow Cat
When I would like it to look like this:
Ant Ape Bear
Bug Cat Crow
Does that make any sense? Is there a way to do that - to get it to sort by
row?
Thanks for the help! |
|
| Back to top |
|
 |
SVC External

Since: Jun 01, 2005 Posts: 250
|
Posted: Wed Dec 28, 2005 1:30 pm Post subject: RE: Sorting Text In Table [Login to view extended thread Info.] Archived from groups: per prev. post (more info?) |
|
|
You can't really do this in a Word table. However, there is a workaround.
Table> Convert > Table to text and Separate the text with Paragraph marks.
Then select the text and click Table > Sort, By Paragraphs , Type: Text and
Ascending. Now Table > Convert > Text to table, use 3 columns and Separate
text at: Paragraph.
"Tiffany" wrote:
> I have a table that has 3 columns and about 10 rows. I am trying to sort the
> text in the boxes so they are in alphabetical order. My problem is that when
> I push sort it will only sort by column, and not by row. For example, say the
> first couple of rows look like this:
> Bear Ape Cat
> Ant Crow Bug
>
> Then when I push sort it sorts the columns into alphabetical order but not
> the rows, and it shows up like this:
> Ant Ape Bug
> Bear Crow Cat
>
> When I would like it to look like this:
> Ant Ape Bear
> Bug Cat Crow
>
> Does that make any sense? Is there a way to do that - to get it to sort by
> row?
>
> Thanks for the help!
> |
|
| Back to top |
|
 |
Helmut Weber External

Since: Sep 05, 2005 Posts: 126
|
Posted: Wed Dec 28, 2005 11:30 pm Post subject: Re: Sorting Text In Table [Login to view extended thread Info.] Archived from groups: per prev. post (more info?) |
|
|
Hi Tiffany,
without even trying to handle merged cells,
without nested tables and
without cells containing anything but text,
and assuming you know something about macros,
then, if the insertion point is in a table,
in principle:
Sub SortRows()
Dim r As Long ' rows
Dim c As Long ' columns
Dim oTbl As Table
Dim oRow As Row
Dim oArr() As String
Set oTbl = Selection.Tables(1)
For r = 1 To oTbl.Rows.Count
oArr = Split(oTbl.Rows(r).Range, chr(13) & chr(7))
WordBasic.sortarray oArr
For c = 2 To UBound(oArr)
' MsgBox c - 1 & " = [" & oArr(c) & "]"
oTbl.Rows(r).Cells(c - 1).Range.Text = oArr(c)
Next
Next
End Sub
--
Greetings from Bavaria, Germany
Helmut Weber, MVP WordVBA
Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de" |
|
| Back to top |
|
 |
Akash Anu External

Since: Jun 20, 2009 Posts: 1
|
Posted: Sat Jun 20, 2009 9:48 pm Post subject: Re: Sorting Text In Table [Login to view extended thread Info.] Archived from groups: per prev. post (more info?) |
|
|
Hi. I have a different question, please read on...
I'm able to sort text in a table. Mine is a 2-column table, and every 20 new
rows I need to select all the rows in the table and click on 'Sort'.
So can it somehow be possible that as soon as I enter a new row it goes into
its right place in the table so that the table looks sorted ? Can it be that
automatic ??
Thanks a lot.
-- Akash.
"Helmut Weber" wrote:
> Hi Tiffany,
>
> without even trying to handle merged cells,
> without nested tables and
> without cells containing anything but text,
>
> and assuming you know something about macros,
> then, if the insertion point is in a table,
> in principle:
>
> Sub SortRows()
> Dim r As Long ' rows
> Dim c As Long ' columns
> Dim oTbl As Table
> Dim oRow As Row
> Dim oArr() As String
> Set oTbl = Selection.Tables(1)
> For r = 1 To oTbl.Rows.Count
> oArr = Split(oTbl.Rows(r).Range, chr(13) & chr(7))
> WordBasic.sortarray oArr
> For c = 2 To UBound(oArr)
> ' MsgBox c - 1 & " = [" & oArr(c) & "]"
> oTbl.Rows(r).Cells(c - 1).Range.Text = oArr(c)
> Next
> Next
> End Sub
>
>
> --
> Greetings from Bavaria, Germany
>
> Helmut Weber, MVP WordVBA
>
> Win XP, Office 2003
> "red.sys" & Chr$(64) & "t-online.de"
> |
|
| Back to top |
|
 |
Doug Robbins - Word MVP External

Since: Jul 14, 2006 Posts: 2665
|
Posted: Sun Jun 21, 2009 2:10 am Post subject: Re: Sorting Text In Table [Login to view extended thread Info.] Archived from groups: per prev. post (more info?) |
|
|
I am afraid not.
--
Hope this helps.
Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.
Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
"Akash Anu" <Akash Anu RemoveThis @discussions.microsoft.com> wrote in message
news:A0032744-81B6-4D13-8AAE-FF22F3B07E87@microsoft.com...
> Hi. I have a different question, please read on...
>
> I'm able to sort text in a table. Mine is a 2-column table, and every 20
> new
> rows I need to select all the rows in the table and click on 'Sort'.
>
> So can it somehow be possible that as soon as I enter a new row it goes
> into
> its right place in the table so that the table looks sorted ? Can it be
> that
> automatic ??
>
> Thanks a lot.
> -- Akash.
>
> "Helmut Weber" wrote:
>
>> Hi Tiffany,
>>
>> without even trying to handle merged cells,
>> without nested tables and
>> without cells containing anything but text,
>>
>> and assuming you know something about macros,
>> then, if the insertion point is in a table,
>> in principle:
>>
>> Sub SortRows()
>> Dim r As Long ' rows
>> Dim c As Long ' columns
>> Dim oTbl As Table
>> Dim oRow As Row
>> Dim oArr() As String
>> Set oTbl = Selection.Tables(1)
>> For r = 1 To oTbl.Rows.Count
>> oArr = Split(oTbl.Rows(r).Range, chr(13) & chr(7))
>> WordBasic.sortarray oArr
>> For c = 2 To UBound(oArr)
>> ' MsgBox c - 1 & " = [" & oArr(c) & "]"
>> oTbl.Rows(r).Cells(c - 1).Range.Text = oArr(c)
>> Next
>> Next
>> End Sub
>>
>>
>> --
>> Greetings from Bavaria, Germany
>>
>> Helmut Weber, MVP WordVBA
>>
>> Win XP, Office 2003
>> "red.sys" & Chr$(64) & "t-online.de"
>> |
|
| Back to top |
|
 |
|
|
|
You can post new topics in this forum You can reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
| |
|
|