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  

delete extra/duplicate rows of table data



 
 
Thread Tools Display Modes
  #1  
Old May 27th, 2004, 03:49 AM
JV
external usenet poster
 
Posts: n/a
Default delete extra/duplicate rows of table data

Hi All,

I have a large MS Word 2003 table of data.

However, after sorting the table I noticed that I have a lot of duplicate
rows of data.

I'm looking for ways to delete the extra/duplicate rows of data other than
manually having to select and delete the rows a few at a time.

I want to make sure I keep one original row of data and just delete the
extra ones.

Any solutions.

Note: If only "coded" solutions are available, I'm only able to cut & past
code...but not write it myself.

Thanks to any and all who can and will help.

Bye,

JV


  #2  
Old May 27th, 2004, 05:26 AM
Klaus Linke
external usenet poster
 
Posts: n/a
Default delete extra/duplicate rows of table data

Hi JV,

For a solution without a macro, see
http://word.mvps.org/FAQs/General/UsingWildcards.htm

A macro solution is easier, once you have put the macro in your normal.dot.
If you need help with that, see
http://word.mvps.org/FAQs/MacrosVBA/CreateAMacro.htm

The macro below will delete duplicate rows. It only looks at the text... If
two rows have the same text, but are formatted differently, the second one
is still deleted.

Regards,
Klaus

Sub DeleteDuplicateRows()
' deletes duplicate rows in the table the cursor is in
Dim tableLoop As Table
Dim rowLoop As Row
Dim strRowOld As String
Dim strRowNew As String

If Selection.Information(wdWithInTable) = False Then
MsgBox "Selection is not in a table", vbCritical, _
"Macro can't run"
Exit Sub
End If

Set tableLoop = Selection.Tables(1)
For Each rowLoop In tableLoop.Rows
strRowNew = rowLoop.Range.Text
If rowLoop.Index 1 Then
If strRowNew = strRowOld Then
rowLoop.Delete
End If
End If
strRowOld = strRowNew
Next rowLoop

End Sub




"JV" wrote:
Hi All,

I have a large MS Word 2003 table of data.

However, after sorting the table I noticed that I have a lot of duplicate
rows of data.

I'm looking for ways to delete the extra/duplicate rows of data other

than
manually having to select and delete the rows a few at a time.

I want to make sure I keep one original row of data and just delete the
extra ones.

Any solutions.

Note: If only "coded" solutions are available, I'm only able to cut &

past
code...but not write it myself.

Thanks to any and all who can and will help.

Bye,

JV




  #3  
Old May 27th, 2004, 09:13 PM
JV
external usenet poster
 
Posts: n/a
Default delete extra/duplicate rows of table data

Hi Klaus,

Mega-thanks for the code solution. You made my day.

FYI: I successfully added the macro to normal.dot, assigned the macro to a
new toolbar button, and ran it on the "duplicate filled table.

Now I have a cleaned up table with no "dupes"

You "code" people are amazing!

Thanks!

-JV

============================


"Klaus Linke" wrote in message
...
Hi JV,

For a solution without a macro, see
http://word.mvps.org/FAQs/General/UsingWildcards.htm

A macro solution is easier, once you have put the macro in your normal.dot.
If you need help with that, see
http://word.mvps.org/FAQs/MacrosVBA/CreateAMacro.htm

The macro below will delete duplicate rows. It only looks at the text... If
two rows have the same text, but are formatted differently, the second one
is still deleted.

Regards,
Klaus

Sub DeleteDuplicateRows()
' deletes duplicate rows in the table the cursor is in
Dim tableLoop As Table
Dim rowLoop As Row
Dim strRowOld As String
Dim strRowNew As String

If Selection.Information(wdWithInTable) = False Then
MsgBox "Selection is not in a table", vbCritical, _
"Macro can't run"
Exit Sub
End If

Set tableLoop = Selection.Tables(1)
For Each rowLoop In tableLoop.Rows
strRowNew = rowLoop.Range.Text
If rowLoop.Index 1 Then
If strRowNew = strRowOld Then
rowLoop.Delete
End If
End If
strRowOld = strRowNew
Next rowLoop

End Sub




"JV" wrote:
Hi All,

I have a large MS Word 2003 table of data.

However, after sorting the table I noticed that I have a lot of duplicate
rows of data.

I'm looking for ways to delete the extra/duplicate rows of data other

than
manually having to select and delete the rows a few at a time.

I want to make sure I keep one original row of data and just delete the
extra ones.

Any solutions.

Note: If only "coded" solutions are available, I'm only able to cut &

past
code...but not write it myself.

Thanks to any and all who can and will help.

Bye,

JV





 




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


All times are GMT +1. The time now is 07:10 AM.


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