I want to use VBA to filter a dump-sheet by 2 columns, with criteria gotten from values on a different sheet in the same workbook.
Used code is:
Sub FilterOnCellValue()
With Sheets("Dump")
.Range("A1:Z10000").AutoFilter Field:=9, Criteria1:=Sheets("ControlPlanning").Range("C1").Value, Field:=23, Criteria1:=Sheets("ControlPlanning").Range("C4").Value
End With
End Sub
For some reason this code filters only one column, while it should be filtering Columns with Number 9 and 23 on 2 different values. As i want to learn from this, explain my thinking error in this piece of VBA. Excel version is 2013, if this makes any difference.
Try to seperate the syntax to 2 lines:
Sub FilterOnCellValue()
With Sheets("Dump").Range("A1:Z10000")
.AutoFilter Field:=9, Criteria1:=Sheets("ControlPlanning").Range("C1").Value
.AutoFilter Field:=23, Criteria1:=Sheets("ControlPlanning").Range("C4").Value
End With
End Sub