I'm trying to delete Table Rows based on which cell(s) are selected. I have a macro that will select the cells for the rows I want to delete (any row with a cell value of "ICO"). I can't figure out how to delete the Table Rows for the selected cells. This is what I have but the "Selection.EntireRow.Delete" apparently does not work in a Table
Sub ico()
'declare variables
Dim ws As Worksheet
Dim SelectCells As Range
Dim xcell As Object
Set ws = Worksheets("Job Log - Client")
Range("Setup").Select
'check each cell in the specific worksheet if the criteria is matching
On Error GoTo ErrorHandler
For Each xcell In ws.UsedRange.Cells
If xcell.Value = "ICO" Then
If SelectCells Is Nothing Then
Set SelectCells = Range(xcell.Address)
Else
Set SelectCells = Union(SelectCells, Range(xcell.Address))
End If
End If
Next
'select the cells with specified value
SelectCells.Select
Selection.EntireRow.Delete
ErrorHandler:
End Sub
Sub ico()
'declare variables
Dim ws As Worksheet
Dim SelectCells As Range
Dim xcell As Object
Set ws = Worksheets("Job Log - Client")
Range("Setup").Select
'check each cell in the specific worksheet if the criteria is matching
On Error GoTo ErrorHandler
For Each xcell In ws.UsedRange.Cells
If xcell.Value = "ICO" Then
If SelectCells Is Nothing Then
Set SelectCells = Range(xcell.Address)
Else
Set SelectCells = Union(SelectCells, Range(xcell.Address))
End If
End If
Next
'select the cells with specified value
SelectCells.Select
Selection.EntireRow.Delete
ErrorHandler:
End Sub