Advanced filter using vba (adding a second filter on the same page)

Connor16

New Member
Joined
Jul 19, 2018
Messages
3
Hello,

I have recently posted about an issue I had doing this advanced filter. After testing a few things I got it to work. However, it only allows me to filter by one column. I need it to filter by two columns. For example, in the code shown below I put C2 were the data validation box (or list) goes but I can't put another box next to it to further filter the row (if that makes sense?) . Anyways, the real question is: how do you adjust this code to allow for the range to be more than just C2 (by the target address) and then correspondingly change the criteria range to "C1:D2". (I can post the file but I will have to change the information since it is confidential :p)

Private Sub Worksheet_Change(ByVal Target As Range)
'Updateby Extendoffice 20160606
If Target.Address = Range("C2").Address Then
'if it's "All" then
' put all back
'Else
Range("A4:L73").CurrentRegion.AdvancedFilter Action:=xlFilterCopy, CriteriaRange:=Range("C1:C2"), CopyToRange:=Range("A77:L77")
Debug.Print "foo"
'End If
End If
End Sub
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.

Forum statistics

Threads
1,214,596
Messages
6,120,438
Members
448,966
Latest member
DannyC96

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