View Single Post
  #7   Report Post  
Jay Freedman
 
Posts: n/a
Default

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