Double Click to Filter Multiple Columns

alexdowd2

New Member
Joined
Apr 15, 2022
Messages
19
Office Version
  1. 365
  2. 2021
Platform
  1. Windows
  2. MacOS
I have 2 sheets, one is a library of sorts (Sheet1) that has an Id column and then corresponding filter values for columns on Sheet2. That Id column from Sheet1 is NOT on Sheet2. Conceptually, what I want to be able to do is click on the Id column on Sheet1, then filter Sheet2 based on the values in that Id's row, which correspond to values in columns on Sheet2 (the column header names are the same). For example, sample data may look like this:

Sheet1

IdColorMakeModel
1​
BlueHondaCivic
2​
GrayFordTaurus
3​
GreenHondaInsight
4​
GreenTeslaModel S

Sheet2

ColorMakeModel
BlueHondaCivic
GrayFordTaurus
GreenHondaInsight
GreenTeslaModel S

Use Case: I double click 1 on Sheet1 and that filters Sheet2 on all records where Color = Blue, Make = Honda, Model = Civic.
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
Hi & welcome to MrExcel.
How about
VBA Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
   If Target.Column = 1 Then
      Cancel = True
      If Target.Value = "" Then Exit Sub
      With Sheets("Sheet2").Range("A1")
         .AutoFilter 8, Target.Offset(, 1)
         .AutoFilter 9, Target.Offset(, 2)
         .AutoFilter 10, Target.Offset(, 3)
      End With
   End If
End Sub
 
Upvote 0
I'm getting a AutoFitler method of Range class failed error on .AutoFilter 8, Target.Offset(, 1)
 
Upvote 0
Oops forgot to change the fields after testing.
Change the 8,9 & 10 to 1,2 & 3 respectively.
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0
You're welcome & thanks for the feedback.
Hi again, so I applied this to my real life scenario (same idea just more columns) and the filter is selecting the correct columns but instead of selecting the criteria it appears to be just clearing the filter (so it's removing all records), any ideas about that?
 
Upvote 0
Are you sure that there are rows which match all criteria?
 
Upvote 0
Are you sure that there are rows which match all criteria?
Yes, I isolated it to only affect 1 column to test that and I have the possible combinations based on a pivot table from the main data so I know all combos are there. When i manually select the filter no boxes are checked.
 
Upvote 0
Are you reading the values from the pivot?
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,284
Members
452,630
Latest member
OdubiYouth

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