Sorting by number

M

Mango

If I number a long column of cells by clicking the numbering function, I am
unable to sort the cells by those automatically inserted numbers.

I'm trying to reverse the order of the cells displayed by my table.

For instance I have a table of daily data. I want to use the numbering
function to identify the cells and then reverse the order in which they are
displayed by sorting them in descending order (from the highest or last
number to the first) But Word won't sort numbers I assign to the column of
data.

If, however, I manually number an empty column one cell at a time, Word will
sort the column (and each row of cells associated with it) by number. But
that process is much too slow.
 
S

Suzanne S. Barnhill

You can apply auto numbering and then convert the numbers to text as
follows:

Press Alt+F11 to open the VBA Editor and Ctrl+G to get to the Immediate
window. In that window, type
ActiveDocument.ConvertNumbersToText
and press Enter.

Note that the above macro will convert all numbers in the active document.
I'm no good with VBA, but I suspect there must be some way to run this macro
on just selected text. I did try using:
Selection.ConvertNumbersToText
but got an error message. Perhaps someone more knowledgeable can provide the
required macro.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
http://word.mvps.org
 
J

Jay Freedman

I'm not sure which "numbering function" you're using (there are several), but
remove it and try this instead:

- In the first cell of the column, use Insert > Field and choose the Seq field
name. In the "advanced field properties" box of the dialog, after the letters
SEQ and the space character, type any letter. Click OK.

- Copy the first cell to the clipboard. Select the whole column and paste. You
should now see the number 1 in each cell of the column. Press the F9 key to
update all the fields, and they'll become sequential numbers.

- Use Table > Sort and choose to sort by that column, in descending order.

If you update fields again (which usually happens when you print or
print-preview), the Seq fields will renumber themselves in ascending order,
although the rest of the table won't change. If you don't want that to happen,
select the whole table (before or after sorting) and press Ctrl+F11 to lock the
fields, or press Ctrl+Shift+F9 to "unlink" (change them to plain text).

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so all
may benefit.
 
J

Jay Freedman

It's possible, but far from intuitive. If the cursor is anywhere within the
table to be sorted, this will convert all numbering (and LISTNUM fields) in the
table to plain text but won't affect the rest of the document:

Selection.Tables(1).Range.ListFormat.ConvertNumbersToText

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so all
may benefit.
 
M

Mango

The numbering function I am using is to simply click on the toolbar
"Numbering" icon (between Line Spacing and Bullets).

I'll print out your advice and see if I can work it through. You're right;
it's far from intuitive.

Also merely finding my way back to this discussion group was a confusing
chore. I got an email notifying me that there was a response to my post, but
my neither of two browsers would take me to the response. It merely
displayed a blank page and told me it was "Done". Figuring my own way back
to the discussion group was an adventure in being Lost in Cyberspace. I'm
going to bookmark the page.
 
M

Mango

It did indeed work. However the F9 key did not update the cells/fields for
me so I did a print-preview and that did it. Then I was able to sort as I
wanted.

Thank you both. I didn't expect my request to be so involved in working
below the surface of things, so I had been very frustrated trying to
understand what was wrong or why I couldn't find an answer.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top