Filter with multiple criteria

All2Cheesy

Board Regular
Joined
Mar 4, 2015
Messages
127
Hi all,

I need to create a macro which allows for the current data on screen (in this case freight) to be filtered by where it is going, and also where it is coming from. The code to do this is below, however, I can only ever do one or the other. Would it be possible to have my spread sheet filter by 'criteria 1' OR 'criteria 2'?

Code:
Sub SYDRETURN()

'Show Sydney
    Range("A6:I549").AdvancedFilter Action:=xlFilterInPlace, CriteriaRange:= _
        Range("B4:B5"), Unique:=False
    Range("A6:I549").AdvancedFilter Action:=xlFilterInPlace, CriteriaRange:= _
        Range("AB4:AB5"), Unique:=False

End Sub

Many thanks in advance. :)
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
Filter for Matching Data in Two Columns

Use one contiguous range for the filter criteria something like this...
Excel Workbook
AB
1ToFrom
2Sydney
3Sydney
Sheet


To: and From: are the column Headers
The two column criteria offset by one row act as OR (same row would be AND).

Code:
    Range("A6:I549").AdvancedFilter Action:=xlFilterInPlace, CriteriaRange:= _
        [B]Range("A1:B3")[/B], Unique:=[color=darkblue]False[/color]
 
Upvote 0
Filter for Matching Data in Two Columns

Use one contiguous range for the filter criteria something like this...
Excel Workbook
AB
1ToFrom
2Sydney*
3*Sydney
Sheet


To: and From: are the column Headers
The two column criteria offset by one row act as OR (same row would be AND).

Code:
    Range("A6:I549").AdvancedFilter Action:=xlFilterInPlace, CriteriaRange:= _
        [B]Range("A1:B3")[/B], Unique:=[color=darkblue]False[/color]



Looks like this has done the trick. Thanks!
 
Upvote 0

Forum statistics

Threads
1,214,644
Messages
6,120,709
Members
448,983
Latest member
Joaquim_Baptista

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