Jase Alexander
asked on
Deleting rows if cell contains text
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
J
ToDoList.xlsm
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.
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
J
ToDoList.xlsm
ASKER
Hey RG
Thanks so much for your help
Just a quick question .... is there a way in which it can be modified to 'unhide' the rows if I re-click the button?
If not, no worries.
J
Thanks so much for your help
Just a quick question .... is there a way in which it can be modified to 'unhide' the rows if I re-click the button?
If not, no worries.
J
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks RG
Amazing solution as always - thank you so much for your help
J
Amazing solution as always - thank you so much for your help
J
pls try
Open in new window
regards