Userform filter datas by two combobox criteria.

asyamonique

Well-known Member
Joined
Jan 29, 2008
Messages
1,107
Code:
Private Sub ComboBox9_Change()Application.ScreenUpdating = False


Dim a, i As Long, ii As Long, b(), n As Long
ListBox1.Clear
With ComboBox9


If .Text = "" Then Exit Sub
If WorksheetFunction.CountIf(Worksheets("taxi").Range("a:a"), .Text) = 0 Then


Exit Sub
End If
a = Worksheets("taxi").Range("a1").Resize(Worksheets("taxi").Range("a" & Rows.Count).End(xlUp).Row, 11).Value
For i = 1 To UBound(a, 1)
If a(i, 1) = .Text Then
n = n + 1: ReDim Preserve b(1 To 11, 1 To n)
For ii = 1 To UBound(a, 2)
b(ii, n) = a(i, ii)
Next
b(3, n) = Format$(a(i, 3), "dd-mmm-yyyy")
b(4, n) = Format$(a(i, 4), "h:mm")
End If
Next
End With
With ListBox1
.ColumnCount = 11
.ColumnWidths = "0;60;80;50;160;160;120;100;100;60;0"
.Column = b
End With
With Application
Me.TextBox18.Value = .Count(.Index(b, 9, 0)) & " Entries"
Me.TextBox16.Value = .Sum(.Index(b, 10, 0))
TextBox16.Text = Format(TextBox16.Text, "###,##0.00") & " Usd"
End With
Application.ScreenUpdating = True
End Sub

Good Day,
I would like to ask you a question in regards filtering the datas by two comboboxes in the same worksheet.
The code given above give me the results by one comboxes correctly everything is fine with that.
Onto the userform I've placed another combobox named combobox11 with the related datas by column "B"
Is it possible to filter all the datas when I do combobox11 change; from column A (by combobox9) and column B (by combobox11)?
And also textbox16 and 18 will give me the related sum results.
Many Thanks
 

Some videos you may like

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.

Subscribe on YouTube

Watch MrExcel Video

Forum statistics

Threads
1,106,078
Messages
5,509,137
Members
408,711
Latest member
EMexcel

This Week's Hot Topics

  • Turn fraction around
    Hello I need to turn a fraction around, for example I have 1/3 but I need to present as 3/1
  • TIme Clock record reformatting to ???
    Hello All, I'd like some help formatting this (Tbl-A)(Loaded via Power Query) [ATTACH type="full" width="511px" alt="PQdata.png"]22252[/ATTACH]...
  • TextBox Match
    hi, I am having a few issues with my code below, what I need it to do is when they enter a value in textbox8 (QTY) either 1,2 or 3 the 3 textboxes...
  • Using Large function based on Multiple Criteria
    Hello, I can't seem to get a Large formula to work based on two criteria's. I can easily get a oldest value based one value, but I'm struggling...
  • Can you check my code please
    Hi, Im going round in circles with a Compil Error End With Without With Here is the code [CODE=rich] Private Sub...
  • Combining 2 pivot tables into 1 chart
    Hello everyone, My question sounds simple but I do not know the answer. I have 2 pivot tables and 2 charts that go with this. However I want to...
Top