Deleting rows if one cell in the row is not a specific color

dunk123

Board Regular
Joined
Feb 14, 2008
Messages
77
Hi all

I have a bunch of customer data that is given to sales reps. Each customer account is on one row, with name, address etc in different columns. Using some basic testing principles, any missing or invalid data has its cell colored using:

Code:
With Selection.Interior
                .Color = 65535
            End With

I now wish to loop through all the rows, testing if any cells in the row are colored. If there are no cells in the entire row that are colored, then I wish to delete the row. I've conceptualized how to do it, but just not quite there.

Any help greatly appreciated. Many thanks.
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Hi. Perhaps like this

Code:
Sub Test2()
Dim LR As Long, LC As Long, i As Long, j As Long, k As Long
LR = Cells.Find(What:="*", SearchDirection:=xlPrevious, SearchOrder:=xlByRows).Row
LC = Cells.Find(What:="*", SearchDirection:=xlPrevious, SearchOrder:=xlByColumns).Column
For i = LR To 1 Step -1
    k = 0
    For j = 1 To LC
        If Cells(i, j).Interior.Color = 65535 Then
            k = 1
            Exit For
        End If
    Next j
    If k = 0 Then Rows(i).Delete
Next i
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,540
Messages
6,120,106
Members
448,945
Latest member
Vmanchoppy

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top