VBA Match Advanced Filter - Excel 2010

tara9

New Member
Joined
Jun 23, 2015
Messages
1
Hello,

I'm new to excel vba and have been trying to write a code for filtering a worksheet based on exact match to my criteria range. For example, column L on my sheet1 includes D2-D26 and I only need to filter D2 and D20. But with the code I currently have I get all cells that start with D2 such as D24 and D26. I have already tried ="=text" solution and it returns no values in my example. Here is what I have so far. I want the code to return exact match of values in R1:S19 and not approximate. Very much appreciate any suggestions you can provide.

Private Sub CommandButton1_Click()
Sheet1.Activate
Sheet1.Range("A1:N1").Select
Selection.Copy
Sheets("Sheet2").Select
Range("A1:N1").PasteSpecial
Columns("A:A").EntireColumn.AutoFit
Columns("B:B").EntireColumn.AutoFit
Columns("C:C").EntireColumn.AutoFit
Columns("D:D").EntireColumn.AutoFit
Columns("E:E").EntireColumn.AutoFit
Columns("F:F").EntireColumn.AutoFit
Columns("G:G").EntireColumn.AutoFit
Columns("H:H").EntireColumn.AutoFit
Columns("I:I").EntireColumn.AutoFit
Columns("J:J").EntireColumn.AutoFit
Columns("K:K").EntireColumn.AutoFit
Columns("L:L").EntireColumn.AutoFit
Columns("M:M").EntireColumn.AutoFit
Columns("N:N").EntireColumn.AutoFit
Range("r4").Select
Sheets("Sort").Select
Application.CutCopyMode = False
Sheet1.Range("A3").Select
Sheets("Sheet2").Select
Sheets("Sort").Range("A1:N100000").AdvancedFilter Action:=xlFilterCopy, CriteriaRange:=Sheets("Sort").Range("R1:S19"), CopyToRange:=Sheets("Sheet2").Range("A1:N1"), Unique:=False
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.

Forum statistics

Threads
1,223,911
Messages
6,175,333
Members
452,636
Latest member
laura12345

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