Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.tables
k1ngy k1ngy is offline
external usenet poster
 
Posts: 1
Default Sort alpha in 1 column with gaps?

How do i sort a-z column 2 only. I can do it if i have a, b, c, d mixed in
column 2 but not if there are gaps, i have shown example below
Any help,
Thanks
A A A A
B D B B B
C C C C
D B D D D

Like this
A A A A
B B B B B
C C C C
D D D D D

  #2   Report Post  
Posted to microsoft.public.word.tables
Graham Mayor Graham Mayor is offline
external usenet poster
 
Posts: 19,312
Default Sort alpha in 1 column with gaps?

It must be the heat? Something is causing correspondents to write gibberish
this morning.
Can you explain in English what it is you are trying to do?

--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org


k1ngy wrote:
How do i sort a-z column 2 only. I can do it if i have a, b, c, d
mixed in column 2 but not if there are gaps, i have shown example
below
Any help,
Thanks
A A A A
B D B B B
C C C C
D B D D D

Like this
A A A A
B B B B B
C C C C
D D D D D



  #3   Report Post  
Posted to microsoft.public.word.tables
Suzanne S. Barnhill Suzanne S. Barnhill is offline
external usenet poster
 
Posts: 33,624
Default Sort alpha in 1 column with gaps?

Think of it as a fruit machine ("slot machine" Stateside). He's got columns
with letters A-Z, and he wants to sort each column separately so that it is
in alpha order, but some of the columns have gaps between letters, and those
have to be placed where they belong (not rise to the top) in order to keep
the B with the other B's, etc. The only solution I can think of would be to
actually insert the appropriate letter and format it as white or possibly
Hidden.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
Word MVP FAQ site: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.

"Graham Mayor" wrote in message
...
It must be the heat? Something is causing correspondents to write

gibberish
this morning.
Can you explain in English what it is you are trying to do?

--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org


k1ngy wrote:
How do i sort a-z column 2 only. I can do it if i have a, b, c, d
mixed in column 2 but not if there are gaps, i have shown example
below
Any help,
Thanks
A A A A
B D B B B
C C C C
D B D D D

Like this
A A A A
B B B B B
C C C C
D D D D D




  #4   Report Post  
Posted to microsoft.public.word.tables
Graham Mayor Graham Mayor is offline
external usenet poster
 
Posts: 19,312
Default Sort alpha in 1 column with gaps?

That crystal ball again?

--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org


Suzanne S. Barnhill wrote:
Think of it as a fruit machine ("slot machine" Stateside). He's got
columns with letters A-Z, and he wants to sort each column separately
so that it is in alpha order, but some of the columns have gaps
between letters, and those have to be placed where they belong (not
rise to the top) in order to keep the B with the other B's, etc. The
only solution I can think of would be to actually insert the
appropriate letter and format it as white or possibly Hidden.


"Graham Mayor" wrote in message
...
It must be the heat? Something is causing correspondents to write
gibberish this morning.
Can you explain in English what it is you are trying to do?

--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org


k1ngy wrote:
How do i sort a-z column 2 only. I can do it if i have a, b, c, d
mixed in column 2 but not if there are gaps, i have shown example
below
Any help,
Thanks
A A A A
B D B B B
C C C C
D B D D D

Like this
A A A A
B B B B B
C C C C
D D D D D



  #5   Report Post  
Posted to microsoft.public.word.tables
Suzanne S. Barnhill Suzanne S. Barnhill is offline
external usenet poster
 
Posts: 33,624
Default Sort alpha in 1 column with gaps?

Well, if you look at the examples he gives...

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
Word MVP FAQ site: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.

"Graham Mayor" wrote in message
...
That crystal ball again?

--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org


Suzanne S. Barnhill wrote:
Think of it as a fruit machine ("slot machine" Stateside). He's got
columns with letters A-Z, and he wants to sort each column separately
so that it is in alpha order, but some of the columns have gaps
between letters, and those have to be placed where they belong (not
rise to the top) in order to keep the B with the other B's, etc. The
only solution I can think of would be to actually insert the
appropriate letter and format it as white or possibly Hidden.


"Graham Mayor" wrote in message
...
It must be the heat? Something is causing correspondents to write
gibberish this morning.
Can you explain in English what it is you are trying to do?

--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org


k1ngy wrote:
How do i sort a-z column 2 only. I can do it if i have a, b, c, d
mixed in column 2 but not if there are gaps, i have shown example
below
Any help,
Thanks
A A A A
B D B B B
C C C C
D B D D D

Like this
A A A A
B B B B B
C C C C
D D D D D






  #6   Report Post  
Posted to microsoft.public.word.tables
Helmut Weber Helmut Weber is offline
external usenet poster
 
Posts: 139
Default Sort alpha in 1 column with gaps?

Hi Suzanne,
hi Graham,

as there was no other amusement on a lazy sunday morning...

I wonder whether this will help the OP,
but is was a nice exercise:

Sub Test1()
Dim bEmp As Boolean ' is empty cell
Dim oTbl As Table
Dim oclm As Column
Dim oCll As Cell
Dim lngCll As Long
Dim cArr() As String
Set oTbl = Selection.Tables(1)
For Each oclm In oTbl.Columns
bEmp = False
oclm.Select
' is there an empty cell?
For Each oCll In Selection.Cells
If Len(oCll.Range.Text) = 2 Then
bEmp = True
Exit For
End If
Next
If bEmp = False Then
' no empty cell then just sort the column
Selection.Sort ExcludeHeader:=False, _
SortColumn:=True, _
sortorder:=wdSortOrderAscending
Else
' there is at least one empty cell
Selection.Sort ExcludeHeader:=False, _
SortColumn:=True, _
sortorder:=wdSortOrderAscending
lngCll = 0
' count not empty cells
For Each oCll In Selection.Cells
If Len(oCll.Range.Text) 2 Then
lngCll = lngCll + 1
End If
Next
' set up an array for the values of the not empty cells
ReDim cArr(1 To lngCll)
lngCll = 0
' put the sorted values into the array
For Each oCll In Selection.Cells
If Len(oCll.Range.Text) 2 Then
lngCll = lngCll + 1
cArr(lngCll) = _
Left(oCll.Range.Text, Len(oCll.Range.Text) - 2)
End If
Next
' unsort the column
ActiveDocument.Undo 1
lngCll = 0
' put the values from the array of not empty cells
' into the not empty cells
For Each oCll In Selection.Cells
If Len(oCll.Range.Text) 2 Then
lngCll = lngCll + 1
oCll.Range.Text = cArr(lngCll)
End If
Next
End If
Next
End Sub

I've used Word's sort algorithm in order to avoid
having to include something like bubblesort
and thus start a discussion about sorting, possibly.

Have a nice day.

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"


Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Alpha sort the Table of Contents in MS Word 2003 Noreen Fratus Microsoft Word Help 3 March 15th 07 05:04 PM
Can you do a linked table of contents and then alpha sort it? Zoe Microsoft Word Help 3 June 14th 06 09:19 PM
Word 2000 Sort/alpha cannot sort in Finnish kirra Microsoft Word Help 1 June 6th 06 07:44 PM
Sort Table of Contents in alpha order Rhonda Microsoft Word Help 1 April 19th 06 07:53 PM
how to sort items in a WORD folder,alpha-wise? swansisle New Users 1 October 1st 05 07:44 PM


All times are GMT +1. The time now is 08:56 PM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"