Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 02-02-2017, 06:40 PM
ThisGuyJohn ThisGuyJohn is offline Deleting rows based on the text in certain cells VBA Windows 7 64bit Deleting rows based on the text in certain cells VBA Office 2016
Novice
Deleting rows based on the text in certain cells VBA
 
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
Reply

Tags
delete rows, macro find text, vba excel



Similar Threads
Thread Thread Starter Forum Replies Last Post
Conditional formating all cells in an array based on adjacent cells deejay Excel 6 12-20-2016 12:00 PM
Deleting rows based on the text in certain cells VBA Deleting rows with partially redundant data Noah14 Excel Programming 1 09-19-2014 11:46 PM
Deleting rows & pushing them up causing issues ep2002 Excel 2 08-29-2014 02:09 AM
Color-fill a range of cells, based on text in a different sheet. Possible? unittwentyfive Excel 2 06-01-2014 06:48 AM
Deleting rows based on the text in certain cells VBA Deleting rows with specific criteria joflow21 Excel 9 11-22-2013 12:10 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 04:03 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft