Hi, I have a VBA/macro code here which autofilters the values in activesheet. My aim is to actually make the VBA code run for the sheets i specify.
Aim: When i press the form button it should filter the values in both the sheets and not just active sheet.
The methods i tried are not working, it would be really helpful if someone could help. Here is the code i have been using.
Sheets i want it to run on : "Prev Month" and "Current Month"
' Macro1 Macro
Dim xWs As Worksheet
Dim rng As Range, res As Variant
If xWs.Name <> "Prev Month" And xWs.Name <> "Current Month" Then
Set rng = Worksheet.AutoFilter.Range.Rows(1)
res = Application.Match("Diaper Range Premium (1) Mainline (2)", rng, 0)
rng.AutoFilter Field:=res, Criteria1:="MAINLINE"
Dim rng1 As Range, res1 As Variant
Set rng1 = Worksheet.AutoFilter.Range.Rows(1)
res1 = Application.Match("Diaper Type (1) - Taped (2) - Pants (9) - Unspecified", rng1, 0)
rng1.AutoFilter Field:=res1, Criteria1:="PANTS"