Wow, that's great. Sorry to be fussy though but I really do need it to work
just on 'selected text' as I have some cells which have a few words at the
start that I don't want sorted.
Can you fine-tune once more?
![Smile](images/smilies/smile.gif)
--
Thanks.
CJSnet
(Remove TEETH to reply by e-mail.)
"Jay Freedman" wrote in message
news
![Embarrassment](images/smilies/redface.gif)
On Mon, 9 May 2005 14:04:42 +0100, "CJSnet"
wrote:
I get an error 5992 that the document has mixed cell widths, which is
true.
However not for the cells I want to sort.
I think the best overall way to do this is for the Macro to only work on
'selected text'. Can that be done?
Ideally I'd just select each cell I want to sort (as there are actually
some
I don't), then run the macro.
Yes, we can do that... You don't even have to select the whole cell;
just put the cursor anywhere in the cell you want to sort, then run
this version of the macro.
Sub SortInOneCell()
Dim oRg As Range
If Not Selection.Information(wdWithInTable) Then
MsgBox "The cursor isn't in a table."
Exit Sub
End If
Set oRg = Selection.Cells(1).Range
oRg.MoveEnd unit:=wdCharacter, Count:=-1
With oRg.Find
.Text = ", "
.Replacement.Text = "^p"
.Wrap = wdFindStop
.Execute Replace:=wdReplaceAll
End With
oRg.Sort
Set oRg = Selection.Cells(1).Range
oRg.MoveEnd unit:=wdCharacter, Count:=-1
With oRg.Find
.Text = "^p"
.Replacement.Text = ", "
.Wrap = wdFindStop
.Execute Replace:=wdReplaceAll
End With
End Sub
--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org