#1
|
||||
|
||||
Delete Table Rows with no highlighting
Following on from https://www.msofficeforums.com/155435-post6.html, I'm manually deleting rows that has no highlights. This is tooo freaking long with 10K rows. There must be a macro. I'm trying to figure a way to delete table Rows, that has NO HIGHLIGHTS.
I don't want to go to bed at 4-5 in the morning and I can't figure it out. Do you have a ready scrpit that I could use. I'm sooo sorry to ask. I'm not that bad, but not as good as you pro's. Cendrinne |
#2
|
||||
|
||||
So basically, you only want to keep the rows that have just 'Inc.' or 'Ltd.' in one of the cells? In which column are those highlighted cells to be found?
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#3
|
||||
|
||||
Well actually, I've highlighted other items to correct, so I was looking for a script that if there is any items highlighted in a row, Keep, but DELETE all other rows, if there is NO Hightlights.
I'm still searching google and Bing, but coming up empty. Or if a table row of 2 columns, has NO HIGHLIGHTED COLOR, delete the content of the row, I do have a macro to delete empty rows. If that would be easier. Cendrinne |
#4
|
||||
|
||||
Perhaps:
Code:
Sub Demo() Application.ScreenUpdating = False Dim RngFnd As Range, RngDel As Range With Selection.Tables(1) Set RngFnd = .Range: Set RngDel = .Range RngDel.Collapse wdCollapseStart With .Range With .Find .ClearFormatting .Replacement.ClearFormatting .Text = "" .Replacement.Text = "" .Forward = True .Wrap = wdFindStop .Highlight = True .Format = True .MatchWildcards = False End With Do While .Find.Execute If .InRange(RngFnd) = False Then Exit Do If .Cells(1).RowIndex > RngDel.Cells(1).RowIndex Then RngDel.End = .Tables(1).Cell(.Cells(1).RowIndex - 1, 1).Range.End RngDel.Rows.Delete End If RngDel.Start = .Tables(1).Rows(.Cells(1).RowIndex).Range.End + 1 .End = .Cells(1).Range.End If .Information(wdAtEndOfRowMarker) = True Then .End = .End + 1 .Collapse wdCollapseEnd Loop End With If RngDel.Information(wdWithInTable) = True Then If RngDel.Cells(1).RowIndex <= .Rows.Count Then RngDel.End = .Range.End RngDel.Rows.Delete End If End If End With Application.ScreenUpdating = True End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#5
|
||||
|
||||
WOW WOW WOW, Paul, I don't know what you did, but it's P E R F E C T. Wow, I'll try to analyze another time, how you did that, cause now I'm too tired but wow is the only word I can say
Thank you a million |
#6
|
||||
|
||||
Just to let you know, it works so well, that I've tried to put on column 1 a highlighted cell, but not the other, then on many rows below I've tested to put on Column 2 a highlighted cell, but not on the first, and it did amazingly as the previous test
So that is amazing Night smart man |
#7
|
||||
|
||||
Yes, I coded it so it doesn't matter which column has the highlighting - or how many columns there are.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#8
|
||||
|
||||
Smart thank you
|
Thread Tools | |
Display Modes | |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Delete rows when copying table | kippiebla | Excel Programming | 4 | 05-10-2020 12:18 AM |
Macro delete table rows if cell in first column = $ | Btop | Word VBA | 7 | 02-13-2018 05:36 PM |
Delete Empty Table Rows | cltay87 | Word VBA | 4 | 02-27-2017 04:23 AM |
How to delete the two non-adjacent rows in a table Word | beginner | Word | 2 | 01-05-2015 05:47 AM |
Delete Rows in Protected Table with Form Fields | Elan05 | Word VBA | 23 | 09-11-2014 12:47 PM |