Reverse order numbered list

C

Captain Frog

Hi All,

Is there a simple method to display a numbered list in reverse order? Like
Dave Letterman's Top 10 List: 10, 9, 8... Any help is gratefully
appreciated.

Regards,
Robert
 
G

Greg Maxey

Skipper,

Simple? debatable.

If you select the list of Dave's favorites and run the following macro
(provided each item in the list is an individual paragraph), they will be
numbered as desired.

Sub RevNum()
Dim i As Long
Dim j As Long
Dim myRng As Range
j = Selection.Paragraphs.Count
For i = 1 To Selection.Paragraphs.Count
Set myRng = Selection.Paragraphs(i).Range
myRng.InsertBefore j + 1 - i & ". "
Next i
End Sub
 
G

Greg Maxey

Skipper,

As a 10 is wider than a 1 or 9, you might want to use a Tab instead of a
space.

Sub RevNum()
Dim i As Long
Dim j As Long
Dim myRng As Range
Selection.ParagraphFormat.TabStops.Add Position:=InchesToPoints(0.25)
j = Selection.Paragraphs.Count
For i = 1 To Selection.Paragraphs.Count
Set myRng = Selection.Paragraphs(i).Range
myRng.InsertBefore j + 1 - i & "." & vbTab
Next i
End Sub
 
G

Greg Maxey

Suzanne,

I am aware of that link, and didn't recommend it as the user seemed to
already have a list that he needed to number in reverse. So select it and
run the macro. Cindy's method is good, yet sort of impractical. I mean your
have to know the high number in advance, set up the fields and then type the
sequence.

Consider:
one
two
three
four
five
six
seven
eight
nine
ten

It is much easier to select that then run my proposed macro than it is to
set up the field codes, save then (I guess as AutoTex) and then type the
list (would you agree?)

The challenge (and I can't figure it out) is to create such a sequence as my
method and Cindy's does quite well and then delete one of the sequence
members and the list update accordingly. I mean consider the following (in
no particular order):

10. Rolling Stones
9. Little Feat
8. Crosby, Stills, Nash and Young
7. The Doors
6. U2
5. Johnny Cash
4 Jewel
3. Brotha Iz
2. Alice Cooper
1. Johnny Love Jazz

Lets delete one of the members (say number 5). Wouldn't it be nice if the
result would be:

9. Rolling Stones
8. Little Feat
7. Crosby, Stills, Nash and Young
6. The Doors
5. U2
4 Jewel
3. Brotha Iz
2. Alice Cooper
1. Johnny Love Jazz

I have been cracking my small skull trying to achieve the desired result
described above. Hoping a small guy or gal will provide.
 
G

Greg Maxey

Here is hoping that anyone that reads my posts will excuse my terrible
spelling. By "small" I meant of course "smart."
 
D

Doug Robbins - Word MVP

Here's an old one of mine that could probably be re-written so that it
doesn't use the Selection object:

' Macro created 25/04/1999 by Doug Robbins to apply/re-apply reverse
sequential numbering

'

Numparas = Selection.Paragraphs.Count

Selection.MoveLeft Unit:=wdCharacter, Count:=1

ActiveWindow.View.ShowFieldCodes = Not ActiveWindow.View.ShowFieldCodes

Selection.Extend

Selection.MoveRight Unit:=wdCharacter, Count:=1

If InStr(Selection.Text, "SEQ") > 0 Then

Selection.MoveRight Unit:=wdCharacter, Count:=2

Selection.Delete Unit:=wdCharacter, Count:=1

Else

Selection.Collapse Direction:=wdCollapseStart

End If

Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, _

PreserveFormatting:=False

Selection.TypeText Text:="=" & Numparas + 1 & "-"

Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, _

PreserveFormatting:=False

Selection.TypeText Text:="SEQ ""ReverseList"""

With Selection.ParagraphFormat

.LeftIndent = CentimetersToPoints(1.27)

.FirstLineIndent = CentimetersToPoints(-1.27)

End With

Selection.MoveRight Unit:=wdCharacter, Count:=4

Selection.InsertAfter "." & vbTab

Counter = 1

While Counter < Numparas

Selection.Move Unit:=wdParagraph, Count:=1

Selection.Extend

Selection.MoveRight Unit:=wdCharacter, Count:=1

If InStr(Selection.Text, "SEQ") > 0 Then

Selection.MoveRight Unit:=wdCharacter, Count:=2

Selection.Delete Unit:=wdCharacter, Count:=1

Else

Selection.Collapse Direction:=wdCollapseStart

End If

Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, _

PreserveFormatting:=False

Selection.TypeText Text:="=" & Numparas + 1 & "-"

Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, _

PreserveFormatting:=False

Selection.TypeText Text:="SEQ ""ReverseList"""

With Selection.ParagraphFormat

.LeftIndent = CentimetersToPoints(1.27)

.FirstLineIndent = CentimetersToPoints(-1.27)

End With

Selection.MoveRight Unit:=wdCharacter, Count:=4

Selection.InsertAfter "." & vbTab

Counter = Counter + 1

Wend

ActiveWindow.View.ShowFieldCodes = Not ActiveWindow.View.ShowFieldCodes

ActiveDocument.Select

ActiveDocument.Fields.Update

--
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
 
D

Doug Robbins - Word MVP

The following is a far superior macro (than my 1999 effort) to
apply/re-apply reverse sequential numbering to a range of paragraphs:

Dim i As Long, Numrange As Range
Set Numrange = Selection.Range
With Numrange
For i = 1 To .Paragraphs.Count
If IsNumeric(.Paragraphs(i).Range.Characters(1)) Then
With .Paragraphs(i).Range
While IsNumeric(.Characters(1))
.Characters(1).Delete
Wend
.Characters(1).Delete
End With
End If
.Paragraphs(i).Range.InsertBefore .Paragraphs.Count - i + 1 & vbTab
Next i
End With


--
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
 
S

Suzanne S. Barnhill

I had forgotten what Cindy's method actually was except that it involved
fields rather than a macro. But for Top 10 countdown lists, it is ideally
suited.
 
C

Captain Frog

Hi Everyone,

Thank you all for your help. Each method will probably do the trick. I'll
set both up and see which suits my need best. I really appreciate the great
job you do for everyone. It is nice to be so ably helped. Happy Valentine's
Day.

Regards,
Robert aka Captain Frog
 

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