• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

How can I add more criteria to this code

Cammandk

Member
This code works well.
I need to get it to work with more criteria.

1. - I would like to be able to have Criteria1: = "I" or "S"

As a new piece of code I need to
2. - I would like to be able to have Criteria = "I" or "S" for Range "I" but also Criteria = "U" for Sh.Range "V".

Code:
Sub APExtract()
  Dim Sh As Worksheet
  Dim lr As Long
 
  For Each Sh In Sheets(Array("Sch6", "Sch7", "Sch8", "Sch9", "Sch10"))
  If Sh.[DJ7] > 0 Then
  Sh.Range("I1", Sh.Range("I" & Rows.Count).End(xlUp)).AutoFilter 1, Criteria1:="I"
 
  lr = Sh.Range("D" & Rows.Count).End(xlUp).Row
  If lr > 1 Then
  Sh.Range("D6", Sh.Range("V65536").End(xlUp)).Copy
  Sheet35.Range("D" & Rows.Count).End(xlUp)(2).PasteSpecial xlPasteValues
  Application.CutCopyMode = False

  End If
  Sh.[i1].AutoFilter
  End If
 
  Next Sh
  Sheet35.Select
 
End Sub

Thanks
DK
 
Last edited by a moderator:
@ Cammandk,

Pls edit your post with proper VBA Macro tags.

like as
Code:
[CODE=vb]
Sub APExtract()
........
.........
.........
End Sub
[/CODE]
 
Hi,

As i understand you want the code modification as below!!!

Code:
For 1

Sh.Range("I1", Sh.Range("I" & Rows.Count).End(xlUp)).AutoFilter 1, Criteria1:="I", _
    Operator:=xlOr, Criteria2:="S"

For 2

With Sh.Range("I1", Sh.Range("V" & Rows.Count).End(xlUp))
    .AutoFilter
    .AutoFilter 1, Criteria1:="I", Operator:=xlOr, Criteria2:="S"
    .AutoFilter 14, Criteria1:="U"
End With
 
Back
Top