Userform filter datas by two combobox criteria.

asyamonique

Well-known Member
Joined
Jan 29, 2008
Messages
1,280
Office Version
  1. 2013
Platform
  1. Windows
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
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.

Forum statistics

Threads
1,214,644
Messages
6,120,709
Members
448,983
Latest member
Joaquim_Baptista

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