Hello,
I have this vba code that does the opposite of what i need. It currently deletes any rows that does not contain highlighting but need it do do the opposite. It had Colorindex = 19 which deleted all the rows not highlighted so I changed the index color to -4142 and it runs without error but doesn't do anything. hoping someone could point me to what I am missing.
I have this vba code that does the opposite of what i need. It currently deletes any rows that does not contain highlighting but need it do do the opposite. It had Colorindex = 19 which deleted all the rows not highlighted so I changed the index color to -4142 and it runs without error but doesn't do anything. hoping someone could point me to what I am missing.
VBA Code:
Sub ShadedRow()
Dim cel As Range, rng As Range, uRng As Range, c As Long, R As Long
Set rng = ActiveSheet.UsedRange
Set uRng = rng.Offset(rng.Rows.Count).Resize(1, 1)
For R = 2 To rng.Rows.Count
For c = 1 To rng.Columns.Count
Set cel = rng.Cells(R, c)
If Not cel.EntireRow.Interior.ColorIndex = -4142 Then
Set uRng = Union(uRng, cel)
Exit For
End If
Next c
Next R
uRng.EntireRow.Delete
End Sub