VBA Autofilter With Multiple Criteria Using Variables

前端 未结 1 2000
闹比i
闹比i 2020-12-19 20:50

EDIT: To fix the issue, I changed Dim Placed As Range to As Long. I then changed

Set Placed = Rows(\"3:3\").Find(\"Placed\", Range         


        
相关标签:
1条回答
  • 2020-12-19 21:08

    No, it's an issue with the Field:= parameter. You have it set to Placed, and you have assigned the Placed variable to a cell. It needs to be a column number. For example, if the Placed column is column D and your data starts in column A, the Field should be 4, because it is the fourth column. If the placed column is the last column, you could set Field equal to your lastColumn variable:

    ActiveSheet.Range(Rng1, Rng2).AutoFilter Field:=lastColumn, Criteria1:=Array(Opt1, Opt2, Opt3, Opt4, Opt5, Opt6, "="), Operator:=xlFilterValues
    
    0 讨论(0)
提交回复
热议问题