bino1121
New Member
- Joined
- Apr 26, 2023
- Messages
- 14
- Office Version
- 365
- 2021
- 2019
- 2016
- 2013
- 2011
- 2010
- 2007
- Platform
- Windows
Sub Advanced_Filter()
Dim Ws1 As Worksheet
Dim Ws2 As Worksheet
Dim dataSet As Long
Dim setCriteria As Long
Set Ws1 = Workbooks("Template Report.xlsx").Sheets(1)
Set Ws2 = Workbooks("Template Report.xlsx").Sheets(2)
dataSet = Ws1.Range("A" & Ws1.Rows.Count).End(xlUp).Row
setCriteria = Ws2.Range("B" & Ws2.Rows.Count).End(xlUp).Row
Range("dataSet").AdvancedFilter Action:=xlFilterInPlace, CriteriaRange:= _
Range("setCriteria"), Unique:=False
End Sub
I am trying to advanced filter Sheet 1 from A3 to xldown (variable range) by sheet 2 from B1 xldown (Variable range) The bold section is where I get the current error Run time error 1004 Method 'Range' of object_'Global' Failed
but the goal is to filter sheet1 in place from A3 to xldown by a list on sheet2 in the same workbook starting from B1 to xldown.
Dim Ws1 As Worksheet
Dim Ws2 As Worksheet
Dim dataSet As Long
Dim setCriteria As Long
Set Ws1 = Workbooks("Template Report.xlsx").Sheets(1)
Set Ws2 = Workbooks("Template Report.xlsx").Sheets(2)
dataSet = Ws1.Range("A" & Ws1.Rows.Count).End(xlUp).Row
setCriteria = Ws2.Range("B" & Ws2.Rows.Count).End(xlUp).Row
Range("dataSet").AdvancedFilter Action:=xlFilterInPlace, CriteriaRange:= _
Range("setCriteria"), Unique:=False
End Sub
I am trying to advanced filter Sheet 1 from A3 to xldown (variable range) by sheet 2 from B1 xldown (Variable range) The bold section is where I get the current error Run time error 1004 Method 'Range' of object_'Global' Failed
but the goal is to filter sheet1 in place from A3 to xldown by a list on sheet2 in the same workbook starting from B1 to xldown.