A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Word » Tables
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Word Table Sort like Headers



 
 
Thread Tools Display Modes
  #1  
Old February 2nd, 2006, 07:50 PM posted to microsoft.public.word.tables
external usenet poster
 
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  
Old February 6th, 2006, 02:00 PM posted to microsoft.public.word.tables
external usenet poster
 
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  
Old February 6th, 2006, 09:43 PM posted to microsoft.public.word.tables
external usenet poster
 
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  
Old February 7th, 2006, 04:18 PM posted to microsoft.public.word.tables
external usenet poster
 
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  
Old February 9th, 2006, 01:16 AM posted to microsoft.public.word.tables
external usenet poster
 
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?



 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Word should catalog misspelled words to study. rndthought General Discussion 38 January 23rd, 2008 11:53 PM
Linking table in Excel to word travis Links and Linking 1 November 19th, 2005 02:30 PM
How do I set right and left alignment on the same line in Word? Matador Page Layout 1 November 9th, 2005 08:32 PM
How to change merge forms from Word Perfect to Microsoft Word Charles Kenyon General Discussion 1 December 30th, 2004 03:35 PM
Here's a shocker Mike Labosh General Discussion 2 October 26th, 2004 05:04 PM


All times are GMT +1. The time now is 01:05 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.