FILTER MORE THAN 2 CRITERIA WITH VBA.

Jungo

New Member
Joined
May 30, 2022
Messages
5
Office Version
  1. 2019
Platform
  1. Windows
IM LOOKING TO FILTER A COLUMN THAT HAS A LIMITLESS LIST OF POSSIBILITIES. THAT COLUMN HOWEVER ALWAYS HAS 5 ITEMS THAT I NEED FILTERED.

I NEED TO KEEP "HEADER", "BLOCKING", "SILL", "CRIPPLE", "STUD" AND DELETE THE REST.

THIS IS WHAT I HAVE SO FAR. BUT IT DOESNT WORK WHEN I ADD ADDITIONAL CRITERIA, AND ARRAY FOR 5 DIFFERENT ITEMS ISNT WORKING OUT FOR ME EITHER.

SOME HELP PLEASE?



Sub Macro5()
'
' FILTER OUT HEADER, BLOCKING, SILL, CRIPPLE, STUD, AND DELETE THE REST
'

'
Range("A1").Select
Range("A1:I10000").Select
Selection.AutoFilter
Range("A1").Select
ActiveSheet.Range("$A$1:$I$10000").AutoFilter Field:=2, Criteria1:= _
"=*HEADER*", Operator:=xlOr, Criteria2:="=*BLOCKING*"
End Sub
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
Hope this helps.
VBA Code:
Sub sample1()
Dim x, c, LR As Long
    LR = Cells(Rows.count, 1).End(xlUp).Row
    ' FILTER OUT HEADER, BLOCKING, SILL, CRIPPLE, STUD, AND DELETE THE REST
    x = Application.Transpose(Range(Range("B2"), Cells(LR, 2)).Value)
    For Each c In Array("HEADER", "BLOCKING", "SILL", "CRIPPLE", "STUD")
        x = Filter(x, c, False)
    Next

  Range("A1").AutoFilter 2, x, xlFilterValues
  If WorksheetFunction.Subtotal(3, Range("B:B")) > 1 Then
    Range(Range("B2"), Cells(LR, 2)).EntireRow.Delete
  End If
  Range("A1").AutoFilter
End Sub
 
Upvote 0
Another approach - run from the active sheet.

VBA Code:
Option Explicit
Sub Exclude_5()
    Dim ws As Worksheet: Set ws = ActiveSheet
    Dim LR As Long, r As Range, arrIn, arrOut, i As Long
    LR = ws.Cells(Rows.Count, 2).End(3).Row

    arrIn = ws.Range("B2:B" & LR).Value
    arrIn = Application.Transpose(Application.Index(arrIn, 0, 1))
    ReDim arrOut(1 To UBound(arrIn))
    
    For i = LBound(arrIn) To UBound(arrIn)
        arrIn(i) = CStr(arrIn(i))
    Next i
    
    For i = LBound(arrIn) To UBound(arrIn)
        Select Case arrIn(i)
            Case Is = "HEADER", "BLOCKING", "SILL", "CRIPPLE", "STUD"
            Case Else
                arrOut(i) = arrIn(i)
        End Select
    Next i

    With ws.Range("A1").CurrentRegion
         .AutoFilter 2, Array(arrOut), 7
         .Offset(1).EntireRow.Delete
         .AutoFilter
    End With
End Sub
 
Upvote 0
ActiveSheet.Range("$A$1:$I$10000").AutoFilter Field:=2, Criteria1:= _
"=*HEADER*", Operator:=xlOr, Criteria2:="=*BLOCKING*"
Can you confirm whether the asterisks in your attempted code indicates that column B might contain additional words in a cell as well as one of the words of interest?
That is, might a row that is to be kept contain "NO BLOCKING TODAY" or would it be just the word "BLOCKING" by itself?
 
Upvote 0
Another approach - run from the active sheet.

VBA Code:
Option Explicit
Sub Exclude_5()
    Dim ws As Worksheet: Set ws = ActiveSheet
    Dim LR As Long, r As Range, arrIn, arrOut, i As Long
    LR = ws.Cells(Rows.Count, 2).End(3).Row

    arrIn = ws.Range("B2:B" & LR).Value
    arrIn = Application.Transpose(Application.Index(arrIn, 0, 1))
    ReDim arrOut(1 To UBound(arrIn))
   
    For i = LBound(arrIn) To UBound(arrIn)
        arrIn(i) = CStr(arrIn(i))
    Next i
   
    For i = LBound(arrIn) To UBound(arrIn)
        Select Case arrIn(i)
            Case Is = "HEADER", "BLOCKING", "SILL", "CRIPPLE", "STUD"
            Case Else
                arrOut(i) = arrIn(i)
        End Select
    Next i

    With ws.Range("A1").CurrentRegion
         .AutoFilter 2, Array(arrOut), 7
         .Offset(1).EntireRow.Delete
         .AutoFilter
    End With
End Sub
Hey Kevin, thanks for the reply.

Two things that keep it from working:
1. the terms "header", "blocking" etc are not exclusive to the cell.. sometimes it might say header #4 or blocking #28. so would a lookup or a "contains" filter work?
2. there is 2 sets of data, so the filter isnt going to the bottom of all the data, just the first break in data.


ill attach the excel file if i can....

So I Downloaded the minisheet uploader, it worked for at moment, and now its not... anywho.. here is the data set below.

i want to keep data the has "header" "blocking" "sill" "cripple" "stud" in column B, and delete the rest of the rows. but as you can see their are multiple header, etc. see below.

let me know if this works

ASH5- ANDERSON SAGE HILLS BLDG 5000 - COMBINED_CutList.xlsx
AB
1QuantityDescription
22 HEADER - DOOR
32 HEADER - DOOR
42 HEADER - DOOR
54 HEADER - DOOR
62 HEADER - DOOR
72 HEADER - DOOR
84 HEADER - DOOR
92 HEADER - DOOR
102 HEADER - DOOR
112 HEADER - DOOR
122 HEADER - DOOR
132 HEADER - DOOR
142 HEADER - DOOR
152 HEADER - DOOR
162 HEADER - DOOR
172 HEADER - DOOR
1812 HEADER - DOOR
192 HEADER - DOOR
202 HEADER - DOOR
212 HEADER - DOOR
222 HEADER - DOOR
232 HEADER - DOOR
242 HEADER - DOOR
254 HEADER - DOOR
264 HEADER - DOOR
272 HEADER - DOOR
282 HEADER - DOOR
292 HEADER - DOOR#2
301 HEADER - SHIM DOOR
314 HEADER - SHIM DOOR
321 HEADER - SHIM DOOR
331 HEADER - SHIM DOOR
342 HEADER - SHIM DOOR
351 HEADER - SHIM DOOR
361 HEADER - SHIM DOOR
371 HEADER - SHIM DOOR
381 HEADER - SHIM DOOR
391 HEADER - SHIM DOOR
401 HEADER - SHIM DOOR
411 HEADER - SHIM DOOR
426 HEADER - SHIM DOOR
431 HEADER - SHIM DOOR
441 HEADER - SHIM DOOR
451 HEADER - SHIM DOOR
461 HEADER - SHIM DOOR
471 HEADER - SHIM DOOR
481 HEADER - SHIM DOOR
492 HEADER - SHIM DOOR
502 HEADER - SHIM DOOR
511 HEADER - SHIM DOOR
521 HEADER - SHIM DOOR
531 HEADER - SHIM GENERIC 2021.03.04#8
542 HEADER - WINDOW
556 HEADER - WINDOW
562 HEADER - WINDOW
572 HEADER - WINDOW
582 HEADER - WINDOW
592 HEADER - WINDOW
602 HEADER - WINDOW
612 HEADER - WINDOW
622 HEADER - WINDOW
632 HEADER - WINDOW
644 HEADER - WINDOW
652 HEADER - WINDOW
662 HEADER - WINDOW
676 HEADER - WINDOW
684 HEADER - WINDOW
692 HEADER - WINDOW
702 HEADER - WINDOW
712 HEADER - WINDOW
722 HEADER - WINDOW
732 HEADER - WINDOW
742 HEADER - WINDOW
752 HEADER - WINDOW
762 HEADER - WINDOW
776 HEADER - WINDOW
784 HEADER - WINDOW
796 HEADER - WINDOW
802 HEADER - WINDOW
812 HEADER - WINDOW
822 HEADER - WINDOW
832 HEADER - WINDOW
844 HEADER - WINDOW
854 HEADER - WINDOW
862 HEADER - WINDOW
872 HEADER - WINDOW
882 HEADER - WINDOW
892 HEADER - WINDOW
902 HEADER - WINDOW
913 HEADER - WINDOW
922 HEADER - WINDOW
934 HEADER - WINDOW
942 HEADER - WINDOW
952 HEADER - WINDOW
962 HEADER - WINDOW
972 HEADER - WINDOW
984 HEADER - WINDOW
992 HEADER - WINDOW
10016 HYPOTENUSE
1014 HYPOTENUSE
1024 HYPOTENUSE
1034 HYPOTENUSE
10416 OPPOSITE
1054 OPPOSITE
1064 OPPOSITE
1074 OPPOSITE
1081 PLATE - 2ND HEADER PLATE
1093 PLATE - 2ND HEADER PLATE
1101 PLATE - 2ND HEADER PLATE
1111 PLATE - 2ND HEADER PLATE
1121 PLATE - 2ND HEADER PLATE
1131 PLATE - 2ND HEADER PLATE
1141 PLATE - 2ND HEADER PLATE
1152 PLATE - 2ND HEADER PLATE
1161 PLATE - 2ND HEADER PLATE
1172 PLATE - 2ND HEADER PLATE
1181 PLATE - 2ND HEADER PLATE
1191 PLATE - 2ND HEADER PLATE
1203 PLATE - 2ND HEADER PLATE
1212 PLATE - 2ND HEADER PLATE
1221 PLATE - 2ND HEADER PLATE
1231 PLATE - 2ND HEADER PLATE
1241 PLATE - 2ND HEADER PLATE
1251 PLATE - 2ND HEADER PLATE
1261 PLATE - 2ND HEADER PLATE
1271 PLATE - 2ND HEADER PLATE
1281 PLATE - 2ND HEADER PLATE
1291 PLATE - 2ND HEADER PLATE
1303 PLATE - 2ND HEADER PLATE
1312 PLATE - 2ND HEADER PLATE
1323 PLATE - 2ND HEADER PLATE
1331 PLATE - 2ND HEADER PLATE
1342 PLATE - 2ND HEADER PLATE
1351 PLATE - 2ND HEADER PLATE
1362 PLATE - 2ND HEADER PLATE
1372 PLATE - 2ND HEADER PLATE
1381 PLATE - 2ND HEADER PLATE
1391 PLATE - 2ND HEADER PLATE
1401 PLATE - 2ND HEADER PLATE
1411 PLATE - 2ND HEADER PLATE
1421 PLATE - 2ND HEADER PLATE
1431 PLATE - 2ND HEADER PLATE
1441 PLATE - 2ND HEADER PLATE
1452 PLATE - 2ND HEADER PLATE
1461 PLATE - 2ND HEADER PLATE
1471 PLATE - 2ND HEADER PLATE
1481 PLATE - 2ND HEADER PLATE
1493 PLATE - 2ND HEADER PLATE
1501 PLATE - 2ND HEADER PLATE
1511 PLATE - BLOCKING GENERIC 2017.04.11#1
1522 PLATE - BLOCKING GENERIC 2017.04.11#1
1532 PLATE - BLOCKING GENERIC 2017.04.11#10
1543 PLATE - BLOCKING GENERIC 2017.04.11#12
1553 PLATE - BLOCKING GENERIC 2017.04.11#16
1562 PLATE - BLOCKING GENERIC 2017.04.11#16
1572 PLATE - BLOCKING GENERIC 2017.04.11#16
1582 PLATE - BLOCKING GENERIC 2017.04.11#18
1591 PLATE - BLOCKING GENERIC 2017.04.11#18
1601 PLATE - BLOCKING GENERIC 2017.04.11#19
1611 PLATE - BLOCKING GENERIC 2017.04.11#19
1621 PLATE - BLOCKING GENERIC 2017.04.11#19
1635 PLATE - BLOCKING GENERIC 2017.04.11#2
1642 PLATE - BLOCKING GENERIC 2017.04.11#20
1651 PLATE - BLOCKING GENERIC 2017.04.11#20
1661 PLATE - BLOCKING GENERIC 2017.04.11#21
1671 PLATE - BLOCKING GENERIC 2017.04.11#21
1681 PLATE - BLOCKING GENERIC 2017.04.11#21
1691 PLATE - BLOCKING GENERIC 2017.04.11#22
1701 PLATE - BLOCKING GENERIC 2017.04.11#23
1711 PLATE - BLOCKING GENERIC 2017.04.11#23
1722 PLATE - BLOCKING GENERIC 2017.04.11#23
1731 PLATE - BLOCKING GENERIC 2017.04.11#23
1741 PLATE - BLOCKING GENERIC 2017.04.11#23
1751 PLATE - BLOCKING GENERIC 2017.04.11#24
1762 PLATE - BLOCKING GENERIC 2017.04.11#24
1771 PLATE - BLOCKING GENERIC 2017.04.11#26
1781 PLATE - BLOCKING GENERIC 2017.04.11#26
1791 PLATE - BLOCKING GENERIC 2017.04.11#26
1801 PLATE - BLOCKING GENERIC 2017.04.11#28
1811 PLATE - BLOCKING GENERIC 2017.04.11#28
18220 PLATE - BLOCKING GENERIC 2017.04.11#3
1831 PLATE - BLOCKING GENERIC 2017.04.11#4
1841 PLATE - BLOCKING GENERIC 2017.04.11#7
1851 PLATE - BLOCKING GENERIC 2021.03.04#1
1861 PLATE - BLOCKING GENERIC 2021.03.04#1
1871 PLATE - BP-1ST
1881 PLATE - BP-1ST
1891 PLATE - BP-1ST
1901 PLATE - BP-1ST
1911 PLATE - BP-1ST
1921 PLATE - BP-1ST
1931 PLATE - BP-1ST
1941 PLATE - BP-1ST
1951 PLATE - BP-1ST
1961 PLATE - BP-1ST
1971 PLATE - BP-1ST
1981 PLATE - BP-1ST
1991 PLATE - BP-1ST
2001 PLATE - BP-1ST
2011 PLATE - BP-1ST
2021 PLATE - BP-2ND#9
2031 PLATE - BP-2ND#9
2041 PLATE - BP-2ND#9
2051 PLATE - BP-2ND#9
2061 PLATE - BP-2ND#9
20787 PLATE - CRIPPLE ABOVE
20810 PLATE - CRIPPLE ABOVE#1
2092 PLATE - CRIPPLE ABOVE#1
21040 PLATE - CRIPPLE ABOVE#1
2112 PLATE - CRIPPLE ABOVE#1
21214 PLATE - CRIPPLE ABOVE#1
2135 PLATE - CRIPPLE ABOVE#2
2141 PLATE - CRIPPLE ABOVE#2
21520 PLATE - CRIPPLE ABOVE#2
2161 PLATE - CRIPPLE ABOVE#2
2177 PLATE - CRIPPLE ABOVE#2
2181 PLATE - CRIPPLE GENERIC 2021.03.04#1
2192 PLATE - CRIPPLE GENERIC 2021.03.04#1
2203 PLATE - CRIPPLE GENERIC 2021.03.04#1
2213 PLATE - CRIPPLE GENERIC 2021.03.04#10
2221 PLATE - CRIPPLE GENERIC 2021.03.04#10
2232 PLATE - CRIPPLE GENERIC 2021.03.04#10
2241 PLATE - CRIPPLE GENERIC 2021.03.04#21
2252 PLATE - CRIPPLE GENERIC 2021.03.04#21
2263 PLATE - CRIPPLE GENERIC 2021.03.04#21
2272 PLATE - CRIPPLE GENERIC 2021.03.04#36
2284 PLATE - CRIPPLE GENERIC 2021.03.04#36
2291 PLATE - CRIPPLE GENERIC 2021.03.04#61
2302 PLATE - CRIPPLE GENERIC 2021.03.04#61
2313 PLATE - CRIPPLE GENERIC 2021.03.04#61
2321 PLATE - CRIPPLE GENERIC 2021.03.04#62
2332 PLATE - CRIPPLE GENERIC 2021.03.04#62
2343 PLATE - CRIPPLE GENERIC 2021.03.04#62
2351 PLATE - CRIPPLE GENERIC 2021.03.04#63
2362 PLATE - CRIPPLE GENERIC 2021.03.04#63
2374 PLATE - CRIPPLE GENERIC 2021.03.04#63
2382 PLATE - CRIPPLE GENERIC 2021.03.04#63
2394 PLATE - CRIPPLE GENERIC 2021.03.04#63
2402 PLATE - CRIPPLE GENERIC 2021.03.04#63
2414 PLATE - CRIPPLE GENERIC 2021.03.04#63
2422 PLATE - CRIPPLE GENERIC 2021.03.04#63
2434 PLATE - CRIPPLE GENERIC 2021.03.04#63
2442 PLATE - CRIPPLE GENERIC 2021.03.04#63
2454 PLATE - CRIPPLE GENERIC 2021.03.04#63
2462 PLATE - CRIPPLE GENERIC 2021.03.04#63
2474 PLATE - CRIPPLE GENERIC 2021.03.04#63
2482 PLATE - CRIPPLE GENERIC 2021.03.04#63
2494 PLATE - CRIPPLE GENERIC 2021.03.04#63
2502 PLATE - CRIPPLE GENERIC 2021.03.04#63
2514 PLATE - CRIPPLE GENERIC 2021.03.04#63
2522 PLATE - CRIPPLE GENERIC 2021.03.04#63
2534 PLATE - CRIPPLE GENERIC 2021.03.04#63
2542 PLATE - CRIPPLE GENERIC 2021.03.04#63
2553 PLATE - CRIPPLE GENERIC 2021.03.04#63
2561 PLATE - CRIPPLE GENERIC 2021.03.04#64
2572 PLATE - CRIPPLE GENERIC 2021.03.04#64
2583 PLATE - CRIPPLE GENERIC 2021.03.04#64
2591 PLATE - CRIPPLE GENERIC 2021.03.04#66
2602 PLATE - CRIPPLE GENERIC 2021.03.04#66
2614 PLATE - CRIPPLE GENERIC 2021.03.04#66
2622 PLATE - CRIPPLE GENERIC 2021.03.04#66
2633 PLATE - CRIPPLE GENERIC 2021.03.04#66
264119 PLATE - CRIPPLE#1
26535 PLATE - CRIPPLE#2
2663 PLATE - CRIPPLE#2
26785 PLATE - CRIPPLE#2
2683 PLATE - CRIPPLE#2
26928 PLATE - CRIPPLE#2
27014 PLATE - CRIPPLE.
2711 PLATE - CRIPPLE.
27234 PLATE - CRIPPLE.
2731 PLATE - CRIPPLE.
27411 PLATE - CRIPPLE.
27560 PLATE - CRIPPLE. ABOVE
2765 PLATE - CRIPPLE. ABOVE#1
2771 PLATE - CRIPPLE. ABOVE#1
27820 PLATE - CRIPPLE. ABOVE#1
2791 PLATE - CRIPPLE. ABOVE#1
2807 PLATE - CRIPPLE. ABOVE#1
2811 PLATE - HEADER PLATE#1
2823 PLATE - HEADER PLATE#1
2831 PLATE - HEADER PLATE#1
2841 PLATE - HEADER PLATE#1
2851 PLATE - HEADER PLATE#1
2861 PLATE - HEADER PLATE#1
2871 PLATE - HEADER PLATE#1
2882 PLATE - HEADER PLATE#1
2891 PLATE - HEADER PLATE#1
2902 PLATE - HEADER PLATE#1
2911 PLATE - HEADER PLATE#1
2921 PLATE - HEADER PLATE#1
2933 PLATE - HEADER PLATE#1
2942 PLATE - HEADER PLATE#1
2951 PLATE - HEADER PLATE#1
2961 PLATE - HEADER PLATE#1
2971 PLATE - HEADER PLATE#1
2981 PLATE - HEADER PLATE#1
2991 PLATE - HEADER PLATE#1
3001 PLATE - HEADER PLATE#1
3011 PLATE - HEADER PLATE#1
3021 PLATE - HEADER PLATE#1
3033 PLATE - HEADER PLATE#1
3042 PLATE - HEADER PLATE#1
3053 PLATE - HEADER PLATE#1
3061 PLATE - HEADER PLATE#1
3072 PLATE - HEADER PLATE#1
3081 PLATE - HEADER PLATE#1
3092 PLATE - HEADER PLATE#1
3102 PLATE - HEADER PLATE#1
3111 PLATE - HEADER PLATE#1
3121 PLATE - HEADER PLATE#1
3131 PLATE - HEADER PLATE#1
3141 PLATE - HEADER PLATE#1
3151 PLATE - HEADER PLATE#1
3161 PLATE - HEADER PLATE#1
3171 PLATE - HEADER PLATE#1
3182 PLATE - HEADER PLATE#1
3191 PLATE - HEADER PLATE#1
3201 PLATE - HEADER PLATE#1
3211 PLATE - HEADER PLATE#1
3222 PLATE - HEADER PLATE#1
3231 PLATE - HEADER PLATE#1
3241 PLATE - SILL DOOR
3254 PLATE - SILL DOOR
3261 PLATE - SILL DOOR
3271 PLATE - SILL DOOR
3282 PLATE - SILL DOOR
3291 PLATE - SILL DOOR
3301 PLATE - SILL DOOR
3311 PLATE - SILL DOOR
3321 PLATE - SILL DOOR
3331 PLATE - SILL DOOR
3341 PLATE - SILL DOOR
3351 PLATE - SILL DOOR
3361 PLATE - SILL DOOR
3376 PLATE - SILL DOOR
3381 PLATE - SILL DOOR
3391 PLATE - SILL DOOR
3401 PLATE - SILL DOOR
3411 PLATE - SILL DOOR
3421 PLATE - SILL DOOR
3431 PLATE - SILL DOOR
3442 PLATE - SILL DOOR
3452 PLATE - SILL DOOR
3461 PLATE - SILL DOOR
3471 PLATE - SILL DOOR
34836 PLATE - SILL GENERIC 2021.03.04#2
3491 PLATE - SILL GENERIC 2021.03.04#23
3501 PLATE - SILL GENERIC 2021.03.04#23
3511 PLATE - SILL GENERIC 2021.03.04#23
3521 PLATE - SILL SLOPED
3531 PLATE - SILL SLOPED
3541 PLATE - SILL SLOPED
3551 PLATE - TP
3561 PLATE - TP
3571 PLATE - TP
3581 PLATE - TP
3591 PLATE - TP
3601 PLATE - TP
3611 PLATE - TP
3621 PLATE - TP
3631 PLATE - VTP
3641 PLATE - VTP
3651 PLATE - VTP
3661 PLATE - VTP
3671 PLATE - VTP
3681 PLATE - VTP
3691 PLATE - VTP
3701 PLATE - VTP
3711 PLATE - VTP
3721 PLATE - VTP
3731 PLATE - VTP
3741 PLATE - VTP
37524 PLATE-CRIPPLE INT DOOR
3768 PLATE-CRIPPLE INT DOOR.
3778 PLATE-SILL INT DOOR
37874 STUD - JACK DOOR
3792 STUD - JACK DOOR#1
380122 STUD - JACK WINDOW
3814 STUD - JACK WINDOW
3826 STUD - JACK WINDOW
38316 STUD- COMMON
3841 STUD- COMMON
38529 STUD- COMMON
38670 STUD- COMMON DOOR
3872 STUD- COMMON DOOR
3886 STUD- COMMON DOOR#3
389134 STUD- COMMON WINDOW
3901 STUD- COMMON#1
3913 STUD- COMMON#1
3929 STUD- COMMON#1
3932 STUD- COMMON#1
39413 STUD- COMMON.#7
39533 STUD- COMMON.#7
3962 STUD- COMMON.#8
3971 STUD- COMMON.#8
3989 STUD- COMMON.#8
3991 STUD- COMMON.#8
4007 STUD- COMMON.#8
4011 STUD- COMMON.#8
4022 STUD- COMMON.#8
4031 STUD- COMMON.#8
4047 STUD- COMMON.#8
40528 STUD- COMMON.#9
40633 STUD- STAGGERED
4071 STUD- STAGGERED
40820 STUD- STAGGERED
4095 STUD- STAGGERED
41053 STUD- STAGGERED
4112 STUD- STAGGERED
4128 STUD- STAGGERED
4131 STUD- STAGGERED
41424 STUD- STAGGERED
4151 STUD- STAGGERED
41628 STUD- STAGGERED
4171 STUD- STAGGERED
4185 STUD- STAGGERED
4193 STUD- STAGGERED#10
4203 STUD- STAGGERED#11
4211 STUD- STAGGERED#11
4221 STUD- STAGGERED#11
4233 STUD- STAGGERED#11
4245 STUD- STAGGERED#11
4254 STUD- STAGGERED#12
4261 STUD- STAGGERED#12
4275 STUD- STAGGERED#12
4284 STUD- STAGGERED#13
4291 STUD- STAGGERED#13
4305 STUD- STAGGERED#13
4313 STUD- STAGGERED#14
4322 STUD- STAGGERED#14
4336 STUD- STAGGERED#14
4341 STUD- STAGGERED#14
4351 STUD- STAGGERED#14
4362 STUD- STAGGERED#14
4375 STUD- STAGGERED#14
4383 STUD- STAGGERED#15
4392 STUD- STAGGERED#15
4406 STUD- STAGGERED#15
4411 STUD- STAGGERED#15
4423 STUD- STAGGERED#16
4435 STUD- STAGGERED#16
44410 STUD- STAGGERED#2
4451 STUD- STAGGERED#2
44616 STUD- STAGGERED#2
4471 STUD- STAGGERED#2
4484 STUD- STAGGERED#2
4495 STUD- STAGGERED#3
4507 STUD- STAGGERED#4
4518 STUD- STAGGERED#5
45212 STUD- STAGGERED#6
4533 STUD- STAGGERED#7
45417 STUD- STAGGERED#8
4552 STUD-COMMON GENERIC 2017.04.11#1
4562 STUD-COMMON GENERIC 2017.04.11#10
4571 STUD-COMMON GENERIC 2021.03.04#53
4581 STUD-COMMON GENERIC 2021.03.04#55
4592 STUD-COMMON GENERIC 2021.03.04#56
4604 STUD-COMMON INT DOOR
4618 STUD-COMMON INT DOOR
4624 STUD-COMMON INT DOOR
46316 STUD-COMMON INT DOOR
4642 STUD-COMMON L
4651 STUD-COMMON L
4663 STUD-COMMON L
4671 STUD-COMMON L
4681 STUD-COMMON L
4694 STUD-COMMON L
4701 STUD-COMMON L
4711 STUD-COMMON L
4721 STUD-COMMON L
4734 STUD-COMMON L
4742 STUD-COMMON L
4751 STUD-COMMON L
4761 STUD-COMMON L
4771 STUD-COMMON L
4781 STUD-COMMON L
4791 STUD-COMMON L
4801 STUD-COMMON L
48114 STUD-COMMON POST
48218 STUD-COMMON POST
4834 STUD-COMMON POST
4847 STUD-COMMON POST
4856 STUD-COMMON POST
48616 STUD-COMMON POST
4877 STUD-COMMON POST
48816 STUD-COMMON POST
4894 STUD-COMMON POST
4909 STUD-COMMON POST
4914 STUD-COMMON POST
49246 STUD-COMMON STUD
4931 STUD-COMMON STUD
4948 STUD-COMMON STUD
4951 STUD-COMMON STUD
49694 STUD-COMMON STUD
4973 STUD-COMMON STUD
49810 STUD-COMMON STUD
4992 STUD-COMMON STUD
50037 STUD-COMMON STUD
50115 STUD-COMMON STUD
50212 STUD-COMMON STUD
5034 STUD-COMMON STUD
5041 STUD-COMMON STUD
5055 STUD-COMMON STUD
506
507
508
509
510
511Board Foot
5123499.86
513103402396.1
514107.7
5150
5160
51710.68
5180
5190
52012.1
5218066.53
5227.52
5232.29
5244090.57
525
526
527QuantityDescription
5281 SHEET
52910 SHEET
5301 SHEET
5311 SHEET
5321 SHEET
5331 SHEET
5342 SHEET - FIREGAURD 2017.04.11#94
5351 SHEET - GENERIC 2017.11.29#1
5361 SHEET - GENERIC 2017.11.29#1
ASH5- ANDERSON SAGE HILLS BLDG
 
Upvote 0
Try the following on a copy of your data:

VBA Code:
Option Explicit
Sub Jungo_1()
    Dim ws As Worksheet
    Set ws = ThisWorkbook.Worksheets("ASH5- ANDERSON SAGE HILLS BLDG")
    Dim lr As Long, lc As Long, i As Long
    Dim arrIn, arrOut
    lr = Cells.Find("*", , xlFormulas, , 1, 2).Row
    lc = Cells.Find("*", , xlFormulas, , 2, 2).Column + 1
    Application.ScreenUpdating = False
    
    arrIn = ws.Range("B2:B" & lr)
    ReDim arrOut(1 To UBound(arrIn), 1 To 1)
    
    For i = 1 To UBound(arrIn)
        If arrIn(i, 1) Like "*HEADER*" Or _
            arrIn(i, 1) Like "*BLOCKING*" Or _
            arrIn(i, 1) Like "*SILL*" Or _
            arrIn(i, 1) Like "*CRIPPLE*" Or _
            arrIn(i, 1) Like "*STUD*" Or _
            arrIn(i, 1) Like "" Then
            arrOut(i, 1) = ""
            Else
            arrOut(i, 1) = 1
        End If
    Next i
    
    ws.Cells(2, lc).Resize(UBound(arrOut)).Value = arrOut
    i = WorksheetFunction.Sum(Columns(lc))
    
    ws.Range(ws.Cells(2, 1), ws.Cells(lr, lc)).Sort Key1:=ws.Cells(2, lc), order1:=1, Header:=2
    If i > 0 Then Cells(2, lc).Resize(i).EntireRow.Delete
    Application.ScreenUpdating = True
End Sub
 
Upvote 0
the terms "header", "blocking" etc are not exclusive to the cell.. sometimes it might say header #4 or blocking #28.
That was the answer to my question too. ;)

Here is another approach that doesn't require looping through the rows. It assumes the relevant sheet is the active sheet (but that could be modified if required)

VBA Code:
Sub Delete_Unwanted()
  Dim rCrit As Range
  
  Application.ScreenUpdating = False
  With Range("A1").CurrentRegion
    Set rCrit = .Offset(, .Columns.Count + 2).Resize(2, 1)
    rCrit.Cells(2).Formula = "=COUNT(SEARCH({""HEADER"",""BLOCKING"",""SILL"",""CRIPPLE"",""STUD""},B2))=0"
    .AdvancedFilter Action:=xlFilterInPlace, CriteriaRange:=rCrit, Unique:=False
    If .Columns(1).SpecialCells(xlVisible).Count > 1 Then .Offset(1).Resize(.Rows.Count - 1).EntireRow.Delete
    If .Parent.FilterMode Then .Parent.ShowAllData
    rCrit.ClearContents
  End With
  Application.ScreenUpdating = True
End Sub


So I Downloaded the minisheet uploader, it worked for at moment, and now its not..
Could this be the issue? If not, what are the symptoms of it "not working"
 
Upvote 0

Forum statistics

Threads
1,224,817
Messages
6,181,149
Members
453,021
Latest member
Justyna P

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