Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.tables
JLP1782
 
Posts: n/a
Default Word Table Sort like Headers

I have a table in MS Word and the first column has a format similar to Headers,
For example:
5.4
5.3.2
6.1
6.18
6.2
6.20
6.2.1
6.3
etc.

I am trying to sort them like a header, where 6.2, 6.2.1 comes before 6.18
etc.
Any suggestions on how to get it working?

  #2   Report Post  
Posted to microsoft.public.word.tables
 
Posts: n/a
Default Word Table Sort like Headers


JLP1782 wrote:
I have a table in MS Word and the first column has a format similar to Headers,
For example:
5.4
5.3.2
6.1
6.18
6.2
6.20
6.2.1
6.3
etc.

I am trying to sort them like a header, where 6.2, 6.2.1 comes before 6.18
etc.
Any suggestions on how to get it working?


have an idea on how to get the sorting to work correctly through a
macro. But, I am not very good at VB using word. I have been trying
for a while to get it working, so, here are the steps:

1) Place the table in a Microsoft Excel worksheet
2) Replace the decimals that are in Column A with A's
3) In the first empty column type the formula =Hex2Dec(A#)...this
converts all of the first column stuff to hex
4) In the next empty column, have a thing where it looks at the first
number in the Column A, and then do a if it is 1, then "A", 2 would be
a "B"...
5) Then the sort would be by step 4 then by step 3 column...
6) Then place it back into word...

Any help with the macro, would be great...

  #3   Report Post  
Posted to microsoft.public.word.tables
Doug Robbins - Word MVP
 
Posts: n/a
Default Word Table Sort like Headers

Answered in microsoft..public.word.vba.general.

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

wrote in message
oups.com...

JLP1782 wrote:
I have a table in MS Word and the first column has a format similar to
Headers,
For example:
5.4
5.3.2
6.1
6.18
6.2
6.20
6.2.1
6.3
etc.

I am trying to sort them like a header, where 6.2, 6.2.1 comes before
6.18
etc.
Any suggestions on how to get it working?


have an idea on how to get the sorting to work correctly through a
macro. But, I am not very good at VB using word. I have been trying
for a while to get it working, so, here are the steps:

1) Place the table in a Microsoft Excel worksheet
2) Replace the decimals that are in Column A with A's
3) In the first empty column type the formula =Hex2Dec(A#)...this
converts all of the first column stuff to hex
4) In the next empty column, have a thing where it looks at the first
number in the Column A, and then do a if it is 1, then "A", 2 would be
a "B"...
5) Then the sort would be by step 4 then by step 3 column...
6) Then place it back into word...

Any help with the macro, would be great...



  #4   Report Post  
Posted to microsoft.public.word.tables
 
Posts: n/a
Default Word Table Sort like Headers

Now that I learned about these wildcards, it is soo much easier!!!!


Sub Macro1()
'
' Macro1 Macro
' Macro recorded 2/7/2006 by Jessica Patla
'
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = ".1"
.Replacement.Text = ".01"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchByte = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchFuzzy = False
.MatchWildcards = True
End With
Selection.Find.Execute Replace:=wdReplaceAll

Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = ".2"
.Replacement.Text = ".02"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchByte = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchFuzzy = False
.MatchWildcards = True
End With
Selection.Find.Execute Replace:=wdReplaceAll

Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = ".3"
.Replacement.Text = ".03"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchByte = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchFuzzy = False
.MatchWildcards = True
End With
Selection.Find.Execute Replace:=wdReplaceAll

Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = ".4"
.Replacement.Text = ".04"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchByte = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchFuzzy = False
.MatchWildcards = True
End With
Selection.Find.Execute Replace:=wdReplaceAll

Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = ".5"
.Replacement.Text = ".05"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchByte = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchFuzzy = False
.MatchWildcards = True
End With
Selection.Find.Execute Replace:=wdReplaceAll

Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = ".6"
.Replacement.Text = ".06"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchByte = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchFuzzy = False
.MatchWildcards = True
End With
Selection.Find.Execute Replace:=wdReplaceAll

Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = ".7"
.Replacement.Text = ".07"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchByte = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchFuzzy = False
.MatchWildcards = True
End With
Selection.Find.Execute Replace:=wdReplaceAll

Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = ".8"
.Replacement.Text = ".08"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchByte = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchFuzzy = False
.MatchWildcards = True
End With
Selection.Find.Execute Replace:=wdReplaceAll

Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = ".9"
.Replacement.Text = ".09"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchByte = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchFuzzy = False
.MatchWildcards = True
End With
Selection.Find.Execute Replace:=wdReplaceAll

Dim tbl As Word.Table

For Each tbl In Word.ActiveDocument.Tables
tbl.Select
Selection.Sort ExcludeHeader:=True, FieldNumber:="Column 1",
SortFieldType _
:=wdSortFieldAlphanumeric, SortOrder:=wdSortOrderAscending,
FieldNumber2 _
:="", SortFieldType2:=wdSortFieldAlphanumeric, SortOrder2:= _
wdSortOrderAscending, FieldNumber3:="", SortFieldType3:= _
wdSortFieldAlphanumeric, SortOrder3:=wdSortOrderAscending,
Separator:= _
wdSortSeparateByCommas, SortColumn:=False, CaseSensitive:=True,
_
LanguageID:=wdEnglishUS, SubFieldNumber:="Paragraphs",
SubFieldNumber2:= _
"Paragraphs", SubFieldNumber3:="Paragraphs"

Next tbl

Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = ".01"
.Replacement.Text = ".1"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchByte = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchFuzzy = False
.MatchWildcards = True
End With
Selection.Find.Execute Replace:=wdReplaceAll


Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = ".02"
.Replacement.Text = ".2"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchByte = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchFuzzy = False
.MatchWildcards = True
End With
Selection.Find.Execute Replace:=wdReplaceAll



Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = ".03"
.Replacement.Text = ".3"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchByte = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchFuzzy = False
.MatchWildcards = True
End With
Selection.Find.Execute Replace:=wdReplaceAll



Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = ".04"
.Replacement.Text = ".4"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchByte = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchFuzzy = False
.MatchWildcards = True
End With
Selection.Find.Execute Replace:=wdReplaceAll



Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = ".05"
.Replacement.Text = ".5"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchByte = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchFuzzy = False
.MatchWildcards = True
End With
Selection.Find.Execute Replace:=wdReplaceAll



Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = ".06"
.Replacement.Text = ".6"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchByte = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchFuzzy = False
.MatchWildcards = True
End With
Selection.Find.Execute Replace:=wdReplaceAll



Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = ".07"
.Replacement.Text = ".7"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchByte = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchFuzzy = False
.MatchWildcards = True
End With
Selection.Find.Execute Replace:=wdReplaceAll



Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = ".08"
.Replacement.Text = ".8"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchByte = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchFuzzy = False
.MatchWildcards = True
End With
Selection.Find.Execute Replace:=wdReplaceAll



Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = ".09"
.Replacement.Text = ".9"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchByte = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchFuzzy = False
.MatchWildcards = True
End With
Selection.Find.Execute Replace:=wdReplaceAll


End Sub

  #5   Report Post  
Posted to microsoft.public.word.tables
Klaus Linke
 
Posts: n/a
Default Word Table Sort like Headers

It should work with a simple sort, too.
The trick is to set the delimiter in the sort options to the "."
("Options... Separate fields at Other:", type in a dot).

You'll have three sort levels. What you'll sort is always "Sort by: Column
1", "Then by: Column 1", "Then by: Column 1".
And the type will always be "Number".
But you'll be "Using: Field 1", "Using: Field 2", "Using: Field 3".
You may have to type in an expression with three "fields", say 5.4.0, in the
first row, so Word "sees" the fields correctly.

Regards,
Klaus




"JLP1782" wrote:
I have a table in MS Word and the first column has a format similar to
Headers,
For example:
5.4
5.3.2
6.1
6.18
6.2
6.20
6.2.1
6.3
etc.

I am trying to sort them like a header, where 6.2, 6.2.1 comes before 6.18
etc.
Any suggestions on how to get it working?



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
Word 97 in Windows XP to maintain formatting Charlie''s Word VBA questions Microsoft Word Help 22 May 20th 23 08:51 PM
apply a template to existing documents Bubba Gump Shrimp Page Layout 2 July 28th 05 04:46 PM
is word perfect compatible with office word? Noreen Microsoft Word Help 1 May 11th 05 11:17 PM
Envelope Address GR New Users 5 April 24th 05 09:48 PM
In Word, how can I see all files (*.*) in "save as"? citizen53 New Users 8 April 4th 05 04:56 PM


All times are GMT +1. The time now is 06:40 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"