Dazzawm
Well-known Member
- Joined
- Jan 24, 2011
- Messages
- 3,786
- Office Version
- 365
- Platform
- Windows
I am a novice when writing code but have written the code below that looks for the word 'Bus' (as an example) in a cell and delete the entire row. How do I change the code so that it deletes the row if the word 'Bus' is amongst other data in the cell and not on its own. Thanks. Also I want the code to look for all case types (BUS, bus, Bus)
Code:
Sub Delete()
Application.ScreenUpdating = False
Dim A As Long
Dim B As Long
Range("R1").Select
A = Selection.CurrentRegion.Rows.Count
For B = 1 To A
If Selection.Value = "Bus" Then 'Change word when necessary
Selection.EntireRow.Delete
Else
Selection.Offset(1, 0).Select
End If
Next B
Application.ScreenUpdating = True
End Sub