Forum Discussion
Filter based on a list of items - multiple items filter
Hello Everyone😊
I have a master list of product that have about 1000 items given by our vendor (like a catalogue but in excel file), the column have price, UPC, product ID etc.. Now, i have a list of product Item that I would like to filter from the master product list. I know i can filter product id , however, this would required me to manual select the product ID. I wonder is there a way i can select a range of product ID that i wanted to filter and apply it to the master list so that only the product in my list are filter out.
Please help
6 Replies
- Rajesh_SinhaIron ContributorPlease confirm through reply whether you are comfortable with Macro then I'll show you few methods fixes the issue.
- ExcelIron ContributorYes sir, please tell me a another method..
- Rajesh_SinhaIron Contributor
Excel ,,
I would like to suggest few Non programming methods as well few Programming.
Non Programming method 1:
How it works:
- Enter IDs to filter, in E145:E148 (is adjustable also).
- Draw Check boxes in A151:A161.
How to draw check boxes.
- From DEVELOPER TAB hit Design.
- Left to it is Insert.
- From ActiceX controls section, find Check box, and plot one by one in A151:A161.
- Select every check box one by one, Right click & from Properties, find Linked Cell and enter related linked cell's reference from Column E. Like for Check box in A151 Linked cell is E151.
- Turn off the Design mode.
- Now click the related Check box for the IDs you want to filter, Excel will fill related cells in Column E with TRUE.
- Now apply Auto Filter for TRUE.
Non Programming method 2:
- Enter this Formula in cell D151 & fill it down.
=COUNTIF($E$145:$E$148,B151)2. Excel will fill cells in column D with 1 and 0s.
3. Now filter for 1s.
Programming method 1:
- Using DEVELOPER TAB then Design & Left to it is Insert then, from ActiceX controls draw the Command button.
- Double click the Command button, you get VB editor.
- Copy & Paste this code.
Private Sub CommandButton1_Click() Dim Arr As Variant Dim i As Integer Arr = WorksheetFunction.Transpose(Worksheets("Sheet1").Range("E145:E148").Value) For i = LBound(Arr) To UBound(Arr) Arr(i) = CStr(Arr(i)) Next i ActiveSheet.Range("$B$150:$B$161").AutoFilter Field:=1, Criteria1:=Arr, Operator:=xlFilterValues End Sub5. Press Alt+Q to return to the Sheet.
6. Now save the workbook as Macro enabled (*.xlsm).
7. Turn Off the Design mode.
8. Now click the command button.
Excel will filter all IDs are stored in cell E145:E148.
Programming method 2:
Before you filter:
How it works:
- Either press Alt+F11 or select Sheet name, Right click & from menu hit View Code.
- You get VB editor, Copy & Paste this code as Standard module.
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean) Dim xcolumn As Integer Dim xvalue As String xcolumn = ActiveCell.Column xvalue = ActiveCell.Value If Application.Intersect(ActiveCell, [Headers]) Is Nothing Then If ActiveCell.Value <> "" Then ActiveSheet.Range("A:B").AutoFilter Field:=xcolumn, Criteria1:=xvalue Cancel = True End If End If End Sub3. Press Alt+Q to return to Sheet.
4. Select A1:B1, and use Range Name method and assign name Headers to them.
5. Save the Workbook as Macro enabled (*.xlsm).
6. Now, Double Click the ID you want filter, you get this.
After you Double click the ID.
Remember that you can't select more than one ID at a time to filter.
**** Note: If you find all these are working for you, then you may mark this post as best Answer as well like.
- SergeiBaklanDiamond Contributor
Or Power Query
- Rajesh_SinhaIron Contributor
Excel ,,
If you want selected/specific Id's to filter then you need programming method, is VBA macro or another is Advance filter or Formula based method.
- NikolinoDEPlatinum Contributor
With your permission, if I can recommend you, add a file (without sensitive data) to your project.
Explain your plans in relation to this file. So you can get a solution that is tailored to your needs much faster.
At the same time, it is much easier for someone who wants to help to understand the subject.
A win-win situation for everyone.
Please no Picture, even if it is said that a picture can say a thousand words, it is certainly not in the case of Excel, on the contrary in some cases.
* Knowing the Excel version and operating system would also be an advantage.
Thank you for your understanding and patience
Nikolino
I know I don't know anything (Socrates)