Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.word.tables
|
|||
|
|||
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
Posted to microsoft.public.word.tables
|
|||
|
|||
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
Posted to microsoft.public.word.tables
|
|||
|
|||
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
Posted to microsoft.public.word.tables
|
|||
|
|||
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
Posted to microsoft.public.word.tables
|
|||
|
|||
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
Posted to microsoft.public.word.tables
|
|||
|
|||
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 | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Alpha sort the Table of Contents in MS Word 2003 | Microsoft Word Help | |||
Can you do a linked table of contents and then alpha sort it? | Microsoft Word Help | |||
Word 2000 Sort/alpha cannot sort in Finnish | Microsoft Word Help | |||
Sort Table of Contents in alpha order | Microsoft Word Help | |||
how to sort items in a WORD folder,alpha-wise? | New Users |