vba multiple filter

kelvin_9

Active Member
Joined
Mar 6, 2015
Messages
444
Office Version
  1. 2019
Hi All,

i am looking for a vba that could do below criteria at the same time, can some one point me out?

first:
VBA Code:
Sub Macro3()
'
' Macro3 Macro
'

'
    Sheets("data").Select
    Rows("1:1").Select
    Selection.AutoFilter
    
    With Range("a1:ab1")
    .AutoFilter Field:=4, Criteria1:="*pickup*"
    .AutoFilter Field:=5, Criteria1:="xlFilterToday"
    
End With

and finally i would like to filter column Y base on sheet2 E49 and column AB base on sheet 2 E50

thank you very much for your help
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Does this do what you want?
VBA Code:
Option Explicit
Sub kelvin_9()
    Dim ws1 As Worksheet, ws2 As Worksheet
    Set ws1 = Worksheets("data")
    Set ws2 = Worksheets("Sheet2")      '<-- *** change sheet name to suit ***
    
    If ws1.AutoFilterMode Then ws1.AutoFilter.ShowAllData
    With ws1.Range("A1").CurrentRegion
        .AutoFilter 4, "*pickup*"
        .AutoFilter 5, 1, 11
        .AutoFilter 25, ws2.Range("E49").Value
        .AutoFilter 28, ws2.Range("E50").Value
    End With
End Sub
 
Upvote 0
Does this do what you want?
VBA Code:
Option Explicit
Sub kelvin_9()
    Dim ws1 As Worksheet, ws2 As Worksheet
    Set ws1 = Worksheets("data")
    Set ws2 = Worksheets("Sheet2")      '<-- *** change sheet name to suit ***
   
    If ws1.AutoFilterMode Then ws1.AutoFilter.ShowAllData
    With ws1.Range("A1").CurrentRegion
        .AutoFilter 4, "*pickup*"
        .AutoFilter 5, 1, 11
        .AutoFilter 25, ws2.Range("E49").Value
        .AutoFilter 28, ws2.Range("E50").Value
    End With
End Sub
thank you very much for your reply, kevin9999

it filtered all the data but not the correct one
2.jpg


thank you very much
 
Upvote 0
I can't tell from the image you posted which columns it didn't filter - the code you posted suggested the filters should be applied to columns 4, 5, 25 & 28 (D, E, Y & AB). Is that not correct?
 
Upvote 0
I can't tell from the image you posted which columns it didn't filter - the code you posted suggested the filters should be applied to columns 4, 5, 25 & 28 (D, E, Y & AB). Is that not correct?
thank you very much for your reply, kevin9999

i apologize for the replied and i finally did it
it is really fantasic

thank you very much for your guidance
 
Upvote 0
thank you very much for your reply, kevin9999

i apologize for the replied and i finally did it
it is really fantasic

thank you very much for your guidance
Sounds like it worked out for you, which is great news, and thanks for the feedback 👍
 
Upvote 0
Do you mean only filtered on column D as "PICKUP" and not "READY TO PICKUP"?
And do you want the filter applied to column D only, and not on any of the other columns previously mentioned in this thread?
 
Upvote 0
If you mean ignore "READY TO PICKUP" in your filtering, then just remove the wildcards (asterisks **) from "*pickup*".
Like this:
VBA Code:
Option Explicit
Sub kelvin_9()
    Dim ws1 As Worksheet, ws2 As Worksheet
    Set ws1 = Worksheets("data")
    Set ws2 = Worksheets("Sheet2")      '<-- *** change sheet name to suit ***
    
    If ws1.AutoFilterMode Then ws1.AutoFilter.ShowAllData
    With ws1.Range("A1").CurrentRegion
        .AutoFilter 4, "pickup"
        .AutoFilter 5, 1, 11
        .AutoFilter 25, ws2.Range("E49").Value
        .AutoFilter 28, ws2.Range("E50").Value
    End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,068
Messages
6,122,950
Members
449,095
Latest member
nmaske

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top