troubleshooting Question

Deleting rows if cell contains text

Avatar of Jase Alexander
Jase AlexanderFlag for United Kingdom of Great Britain and Northern Ireland asked on
Microsoft OfficeMicrosoft ExcelVBA
4 Comments1 Solution116 ViewsLast Modified:
HI Guys

Hope you can help

I have a simple to do list sheet detailing live and completed tasks. Each task has a progress bar on the right and in this, is a conditional format set so when the 'x' key is used, the cell turns green signifying progress.

Ive tried the below code so that if the button is pressed, it scans the sheet in column N and if it finds an 'x' in the cells in Column N, it will hide the row as the task is, in effect, complete.

The code ive assembled is as follows :-

Sub HideRows()
    Dim cell As Range
    Dim DataCount As Integer
    With Worksheets("ToDoList")
        DataCount = Range("A" & Rows.Count).End(xlUp).Row
        For Each cell In Range("N1:N" & DataCount)
            If cell.Contains("x")  Then
                Range(cell.Row).EntireRow.Hidden = True
            End If
        Next cell
    End With
End Sub

However, Im getting an error and not sure what I am doing wrong?

I have attached the sheet - any suggestions and help would be appreciated

Join our community to see this answer!
Unlock 1 Answer and 4 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros