happymacro
New Member
- Joined
- Nov 4, 2017
- Messages
- 18
Hi there:
I tried to delete the whole row if the column contains certain words for example if a column contain "Labor Cost", I want to delete the entire row. The macro I have only can delete exact words that I put in but I would really like to delete both exact words and contain certain words.
Here is what I have but not sure where went wrong.
Dim lastRow As Long
Dim thisRow As Long
Sheets("Sitedata").Select
lastRow = Cells(Rows.Count, 1).End(xlUp).Row
For thisRow = lastRow To 1 Step -1
Select Case Cells(thisRow, 1).Value
Case "Bat", "Apple", Order ID", "Orange"
Cells(thisRow, 1).EntireRow.Delete
End Select
Next thisRow
Sheets("Sitedata").Select
lastRow = Cells(Rows.Count, 1).End(xlUp).Row
For thisRow = lastRow To 1 Step -1
If Cells(thisRow, 1).Value = "LABOR Cost" Then
Cells(thisRow, 1).EntireRow.Delete
End If
Next thisRow
End Sub
I tried to delete the whole row if the column contains certain words for example if a column contain "Labor Cost", I want to delete the entire row. The macro I have only can delete exact words that I put in but I would really like to delete both exact words and contain certain words.
Here is what I have but not sure where went wrong.
Dim lastRow As Long
Dim thisRow As Long
Sheets("Sitedata").Select
lastRow = Cells(Rows.Count, 1).End(xlUp).Row
For thisRow = lastRow To 1 Step -1
Select Case Cells(thisRow, 1).Value
Case "Bat", "Apple", Order ID", "Orange"
Cells(thisRow, 1).EntireRow.Delete
End Select
Next thisRow
Sheets("Sitedata").Select
lastRow = Cells(Rows.Count, 1).End(xlUp).Row
For thisRow = lastRow To 1 Step -1
If Cells(thisRow, 1).Value = "LABOR Cost" Then
Cells(thisRow, 1).EntireRow.Delete
End If
Next thisRow
End Sub