G
Gem_man
I know I have made a few posts recently, but it is not for the lack of trying
to sort it out myself. I am stuck!! Any help would be appreciated.
I have a doc with two words in each paragraph and wish add to each paragraph
the number of occassions that this paragraph is duplicated in the doc, then
delete the duplicates.
ie: List before code
Madrid, Spain
London, England
London, England
London, England
Paris, France
Paris, France
Desired result after code:
London, England (3)
Madrid, Spain (1)
Paris, France (2)
Below is the code I have so far (with the help of Doug and Jay)
I am working on the theory that the number of deleted duplicates (x
variable) represents the number of times that paragraph is duplicated
Can anyone suggest soemthing that might work. I dont think I could stand
another two nights of 3am bedtimes!
Dim i As Long
With Target
.Content.Sort SortOrder:=wdSortOrderAscending
For i = .Paragraphs.Count To 2 Step -1
If .Paragraphs(i).Range.Text = _
.Paragraphs(i - 1).Range.Text Then
.Paragraphs(i).Range.Delete : x = x+1 'number of deletes
equals the numbers of matches
End If
Next i
Do While Len(.Paragraphs(1).Range.Text) = 1
.Paragraphs(1).Range.Delete
Loop
.Activate
End With
to sort it out myself. I am stuck!! Any help would be appreciated.
I have a doc with two words in each paragraph and wish add to each paragraph
the number of occassions that this paragraph is duplicated in the doc, then
delete the duplicates.
ie: List before code
Madrid, Spain
London, England
London, England
London, England
Paris, France
Paris, France
Desired result after code:
London, England (3)
Madrid, Spain (1)
Paris, France (2)
Below is the code I have so far (with the help of Doug and Jay)
I am working on the theory that the number of deleted duplicates (x
variable) represents the number of times that paragraph is duplicated
Can anyone suggest soemthing that might work. I dont think I could stand
another two nights of 3am bedtimes!
Dim i As Long
With Target
.Content.Sort SortOrder:=wdSortOrderAscending
For i = .Paragraphs.Count To 2 Step -1
If .Paragraphs(i).Range.Text = _
.Paragraphs(i - 1).Range.Text Then
.Paragraphs(i).Range.Delete : x = x+1 'number of deletes
equals the numbers of matches
End If
Next i
Do While Len(.Paragraphs(1).Range.Text) = 1
.Paragraphs(1).Range.Delete
Loop
.Activate
End With