Group By

D

Derek Hart

Can I mark a table in Word to Group By the data. So it does not show
duplicate data?

Thank You,
Derek Hart
 
D

Derek Hart

I looked at example 4. I don't understand how that applies. I have a list
of 27 states, but only 4 are unique. How do I list the 4?

Derek Hart
 
J

Jay Freedman

If your list is in the form of one item per paragraph, then select the
list and click Table > Sort > OK. This sorts them so all the
duplicates are grouped together. Then run the wildcard replacement to
remove the duplicate paragraphs. What's left will be the unique items.

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.
 
D

Derek Hart

It does not seem to replace all the duplicates unless I run it multiple
times. This is the code when I recorded a macro.

I had the following:

AZ
AZ
CA
CA
CA
CA
CA
FL
FL
GA

so I want to get

AZ
CA
FL
GA

Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "(*^13)\1"
.Replacement.Text = "\1"
.Forward = True
.Wrap = wdFindAsk
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True
End With
Selection.Find.Execute Replace:=wdReplaceAll

Am I missing something?
 
J

Jay Freedman

Hi Derek,

You're not missing anything, other than the part in the web page that
says "Repeat until nothing is found, to delete all duplicate
paragraphs in the document". The recorder isn't capable of creating a
macro that loops, so you have to add that to the code manually. Change
the line

Selection.Find.Execute Replace:=wdReplaceAll

to

Do While Selection.Find.Execute(Replace:=wdReplaceAll)
Loop

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top