godzilla185
New Member
- Joined
- Sep 27, 2021
- Messages
- 18
- Office Version
- 365
- Platform
- Windows
Hi everyone, if anyone can help me on the below.
I am trying to get a macro that will delete rows if certain cells contact certain text, or even better, delete all rows except ones containing certain text.
The below code works great only problem is it only works on 1 variable "name1", but I need it to remove multiple names (10+)... If there is a simple way for me to elaborate on this code it would be easiest for me, but I tried adding OR/AND to the "name1" and it doesn't work.
Sub pivot()
' Filter_out_text Macro
'
Application.ScreenUpdating = False
Dim i As Long
LR = Range("O" & Rows.Count).End(xlUp).Row
For i = LR To 1 Step -1
If Range("O" & i) = "name1" Then
Rows(i).EntireRow.Delete
End If
Next i
Application.ScreenUpdating = True
End Sub
I am trying to get a macro that will delete rows if certain cells contact certain text, or even better, delete all rows except ones containing certain text.
The below code works great only problem is it only works on 1 variable "name1", but I need it to remove multiple names (10+)... If there is a simple way for me to elaborate on this code it would be easiest for me, but I tried adding OR/AND to the "name1" and it doesn't work.
Sub pivot()
' Filter_out_text Macro
'
Application.ScreenUpdating = False
Dim i As Long
LR = Range("O" & Rows.Count).End(xlUp).Row
For i = LR To 1 Step -1
If Range("O" & i) = "name1" Then
Rows(i).EntireRow.Delete
End If
Next i
Application.ScreenUpdating = True
End Sub