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. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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 | |
|
|