Delete Entire Rows Based on Not Equal to Text

_eNVy_

Board Regular
Joined
Feb 9, 2018
Messages
66
Office Version
  1. 365
Platform
  1. Windows
Hi,

I am making some code that applies a filter and I wish to delete every rows that does not equal TRUE.
Headers are in row 4.
Items when looking at filter include TRUE, FALSE, #NUM!. I just want to delete FALSE and #NUM! and keep all rows that have TRUE.

VBA Code:
Sub OneC_Auto()
   
    Dim lRow                        As Long
    Dim ws1, ws2                    As Worksheet
    Dim rng1, dups, DateTrue        As Range
    Dim r1                          As Integer
   
    Set ws1 = Worksheets("1c boxi")
    Set ws2 = Worksheets("1c client services")
    r = 0
   
    lRow = Cells.Find(What:="*", _
           After:=Range("A1"), _
           LookAt:=xlPart, _
           LookIn:=xlFormulas, _
           SearchOrder:=xlByRows, _
           SearchDirection:=xlPrevious, _
           MatchCase:=False).Row
   
    Set rng1 = Range("AR4:AU" & lRow)
    Set dups = Range("AT4:AT" & lRow)
    Set DateTrue = Range("AU4:AU" & lRow)

    ws1.Range("AR4").Formula = "=TEXTJOIN("","",TRUE,A4,AK4,AL4)"
    ws1.Range("AS4").Formula = "=XLOOKUP(AK4,'PSR lookup'!A:A,'PSR lookup'!B:B,"""")"
    'ws1.Range("AT4").Formula = "=COUNTIF(AR$4:AR4,AR4)"
    ws1.Range("AU4").Formula = "=IF(AND(DATEDIF(P4,$AU$2,""M"")>=12,OR(Q4>$AV$2,Q4="""")),TRUE,FALSE)"
   
    ws1.Range("AR4:AU4").AutoFill _
                                Destination:=rng1, Type:=xlFillDefault
    rng1.Value = rng1.Value
      
    With ActiveSheet
        .AutoFilterMode = False
        With Range("AU3:AU" & lRow)
            .AutoFilter Field:=47, Criteria1:="<>TRUE"
            On Error Resume Next
            .Offsert(1).SpecialCells(12).EntireRow.Delete
        End With
        .AutoFilterMode = False
    End With

Any and all help is appreciated.
eNVy
 
Last edited:

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Stuck on this code for a day and a half.....
A soon as I posted it on here, I found the solution.

VBA Code:
    With ActiveSheet
        .AutoFilterMode = False
        With Range("AU3:AU" & lRow)
            .AutoFilter Field:=1, Criteria1:="<>TRUE"
            On Error Resume Next
            .Offset(1).SpecialCells(12).EntireRow.Delete
        End With
        .AutoFilterMode = False
    End With

OR

VBA Code:
    With ActiveSheet
        .AutoFilterMode = False
        With Range("A3:AU" & lRow)
            .AutoFilter Field:=47, Criteria1:="<>TRUE"
            On Error Resume Next
            .Offset(1).SpecialCells(12).EntireRow.Delete
        End With
        .AutoFilterMode = False
    End With
 
Upvote 0
Solution

Forum statistics

Threads
1,215,327
Messages
6,124,289
Members
449,149
Latest member
mwdbActuary

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top