Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Sorting a block of page number citations

0 views
Skip to first unread message

alfred....@gmail.com

unread,
Jan 29, 2009, 9:24:49 AM1/29/09
to
Not sure in what forum this problem should reside, but I've had luck
here.

I need to sort and delete dupes in a list of page number citations,
all existing in one cell:

1, 1, 3, 5, 7, 9, 2, 2, 4, 6, 8

Needs to appear as

1, 2, 3, 4, 5, 6, 7, 8

In one cell

Please advise if this would be better accomplished in Excel, or VB.

Thanks!

Al

Doug Robbins - Word MVP

unread,
Jan 30, 2009, 2:13:15 AM1/30/09
to
Use:

Set drange = Selection.Cells(1).Range
drange.End = drange.End - 1
Dim m As Variant
Dim i As Long
Dim result As String
result = ""
m = Split(drange, ",")
For i = LBound(m) + 1 To UBound(m)
If InStr(result, m(i)) = 0 Then
result = result & "," & m(i)
End If
Next i
result = Mid(result, 2)
drange.Text = Replace(result, ",", vbCr)
drange.Sort
Set drange = Selection.Cells(1).Range
drange.End = drange.End - 1
drange.Text = Mid(Replace(drange.Text, vbCr, ","), 2)


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

<alfred....@gmail.com> wrote in message
news:59076802-dd5e-4bdc...@u18g2000pro.googlegroups.com...

alfred....@gmail.com

unread,
Jan 30, 2009, 9:44:21 AM1/30/09
to
On Jan 30, 2:13 am, "Doug Robbins - Word MVP"
> <alfred.clout...@gmail.com> wrote in message

>
> news:59076802-dd5e-4bdc...@u18g2000pro.googlegroups.com...
>
> > Not sure in what forum this problem should reside, but I've had luck
> > here.
>
> > I need to sort and delete dupes in a list of page number citations,
> > all existing in one cell:
>
> > 1, 1, 3, 5, 7, 9, 2, 2, 4, 6, 8
>
> > Needs to appear as
>
> > 1, 2, 3, 4, 5, 6, 7, 8
>
> > In one cell
>
> > Please advise if this would be better accomplished in Excel, or VB.
>
> > Thanks!
>
> > Al

I haven't had a chance to test this, but thank you very much for your
time!

Al

0 new messages