Hello Everyone,
I'm having trouble with a macro i'm trying to create.
Somoene already helped me here with a macro I was trying to do which was deleting all line that are not ending with .02. I modified it to add the .12 and .22 condition.
Now I would like the macro to delete everything that is not .XX (by .XX i mean anything)
Is that possible or I would need to enumerate every .XX there is in my sheet (There's quite a lot)
Thanks a lot !
Here's the original macro if it's easier for you to work with
I'm having trouble with a macro i'm trying to create.
Somoene already helped me here with a macro I was trying to do which was deleting all line that are not ending with .02. I modified it to add the .12 and .22 condition.
Now I would like the macro to delete everything that is not .XX (by .XX i mean anything)
Is that possible or I would need to enumerate every .XX there is in my sheet (There's quite a lot)
Thanks a lot !
Here's the original macro if it's easier for you to work with
VBA Code:
Dim lr As Long
Dim r As Long
Dim Rng As Range
Application.EnableEvents = False
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
' Find last row with data in column A
lr = Cells(Rows.Count, "A").End(xlUp).Row
' Loop through all rows backwards and delete ones not meeting conditions
For r = lr To 1 Step -1
If Right(Cells(r, "A"), 3) <> ".02" And Right(Cells(r, "A"), 3) <> ".12" And Right(Cells(r, "A"), 3) <> ".22" Then
If Rng Is Nothing Then Set Rng = Rows(r) Else Set Rng = Union(Rng, Rows(r))
End If
Next r
If Not Rng Is Nothing Then Rng.Delete
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
Application.EnableEvents = True