View Single Post
 
Old 02-02-2017, 06:40 PM
ThisGuyJohn ThisGuyJohn is offline Windows 7 64bit Office 2016
Novice
 
Join Date: Jan 2017
Posts: 6
ThisGuyJohn is on a distinguished road
Default

OK so I figured it out and got it to work
is there any way of simplifying it tho there is 4 if statements and usually about 10,000 to 30,000 rows in my report I run at work and i have to let it run overnight lol
I have tried combining all the IF NOT statements but excel only does whatever is listed first

combined IF NOT statements using ''or" or "and"

Code:
If Not .Range("C1").Value Like "Agent:*" or .Range("C1").Value Like "Date:*" or .Range("M1").Value = "Break (Aux 2 - Agero Aux 4 - MG Break - Aux 71 HRB)" Then
Code:
If Not .Range("C1").Value Like "Agent:*" and .Range("C1").Value Like "Date:*" and .Range("M1").Value = "Break (Aux 2 - Agero Aux 4 - MG Break - Aux 71 HRB)" Then

this is the full code that works

Code:
Sub Filter()
    Dim c As Long
    Dim m As Long
    With ActiveSheet
        For c = .Cells(Rows.Count, "C").End(xlUp).Row To 1 Step -1
        For m = .Cells(Rows.Count, "M").End(xlUp).Row To 1 Step -1
            With .Rows(c)
            With .Rows(m)
                If .Range("P1").Value = "System Issues" Or .Range("P1").Value = "SME Floor Walker" Or .Range("P1").Value = "Coaching" Or .Range("P1").Value = "Not Scheduled" Or .Range("P1").Value = "Not Set Ready" Or .Range("P1").Value = "Available" Or .Range("P1").Value = vbNullString Then
                    If Not .Range("C1").Value Like "Agent:*" Then
                    If Not .Range("C1").Value Like "Date:*" Then
                    If Not .Range("M1").Value = "Break (Aux 2 - Agero Aux 4 - MG Break - Aux 71 HRB)" Then
                        .Delete
                        
                    End If
                    End If
                    End If
                End If
            End With
            End With
            
        Next m
        Next c
    End With
    
End Sub
Reply With Quote