(VBA) Code Amendment Needed To Filter Data From A Worksheet Into A Combobox

kelly mort

Well-known Member
Joined
Apr 10, 2017
Messages
2,169
Office Version
  1. 2016
Platform
  1. Windows
The code below here was written for me by @Fluff some time ago. It's a very wonderful code and I love it.
I have added 2 more comboboxes to use as the criteria for doing my filtering but I am stacked with how to get it tweaked.

The new comboboxes are:
ComboBox3, which will check column Y and ComboBox4, which points to column Z

That is, the values from box1, box3 and box4 must all match in the Worksheet before box2 is populated.

Thanks in advance.
Code:
Private Sub ComboBox1_Click()
   Dim Lst As Variant
   Dim db As Worksheet
   Dim i As Long

   Set db = Sheets("Sheet1")
   With db.Range("B4", db.Range("B" & Rows.Count).End(xlUp))
      Lst = Filter(db.Evaluate("transpose(if(" & .Offset(, 1).Address & "="  & Me.ComboBox1.Value & "," & .Address & ",""#""))"), "#", False)
   End With
   
   Me.ComboBox2.List = Lst
End Sub
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
Bump

Hello again,

I still need help with this challenge.
I was thinking maybe I could not express myself properly in the first post so I want to describe the problem once again.

The code will only run when ComboBox1 is changed or click.
And when that is done, I want to filter only the rows or items in column B that match the contents of ComboBox1 in column C and ComboBox3 in column Yaw and ComboBox4 in column Z.

So once all those conditions are met on a row, I want to filter the data into ComboBox2 as the previous code was doing.

Thanks again.

Link to the other code by @Fluff:
 
Upvote 0
How about
VBA Code:
Private Sub ComboBox1_Click()
   Dim Lst As Variant
   Dim db As Worksheet
   Dim i As Long

   Set db = Sheets("Sheet1")
   With db.Range("B4", db.Range("B" & Rows.Count).End(xlUp))
      Lst = Filter(db.Evaluate("transpose(if((" & .Offset(, 1).Address & "=" & Me.ComboBox1.Value & ")*(" & .Offset(, 23).Address & "=" & Me.ComboBox3.Value & ")*(" & .Offset(, 24).Address & "=" & Me.ComboBox4.Value & ")," & .Address & ",""#""))"), "#", False)
   End With
   
   Me.ComboBox2.List = Lst
End Sub
 
Upvote 0
Solution

Forum statistics

Threads
1,223,893
Messages
6,175,239
Members
452,621
Latest member
Laura_PinksBTHFT

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