Listbox Array calculation by first column

asyamonique

Well-known Member
Joined
Jan 29, 2008
Messages
1,286
Office Version
  1. 2013
Platform
  1. Windows
[TABLE="width: 1576"]
<colgroup><col><col><col><col span="2"><col><col span="2"><col span="2"><col><col span="3"><col></colgroup><tbody>[TR]
[TD]Column A[/TD]
[TD]Column B[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]Column M[/TD]
[TD]Column N[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]MONTH[/TD]
[TD]DATE[/TD]
[TD]CUSTOMER ID#[/TD]
[TD]FIRST NAME[/TD]
[TD]LAST NAME[/TD]
[TD]DATA[/TD]
[TD]DATA[/TD]
[TD]DATA[/TD]
[TD]DATA[/TD]
[TD]DATA[/TD]
[TD]DATA[/TD]
[TD]DATA[/TD]
[TD]POINTS[/TD]
[TD]POINTS[/TD]
[TD]DATA[/TD]
[/TR]
[TR]
[TD]June[/TD]
[TD]7-Jun-2018[/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD]5,000[/TD]
[TD]8,000[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]June[/TD]
[TD]7-Jun-2018[/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD]5,100[/TD]
[TD]8,100[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]June[/TD]
[TD]7-Jun-2018[/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD]5,200[/TD]
[TD]8,200[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]June[/TD]
[TD]7-Jun-2018[/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD]5,300[/TD]
[TD]8,300[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]June[/TD]
[TD]7-Jun-2018[/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD]5,400[/TD]
[TD]8,400[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]June[/TD]
[TD]8-Jun-2018[/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD]5,500[/TD]
[TD]8,500[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]June[/TD]
[TD]8-Jun-2018[/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD]5,600[/TD]
[TD]8,600[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]June[/TD]
[TD]8-Jun-2018[/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD]5,700[/TD]
[TD]8,700[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]June[/TD]
[TD]8-Jun-2018[/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD]5,800[/TD]
[TD]8,800[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]June[/TD]
[TD]8-Jun-2018[/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD]5,900[/TD]
[TD]8,900[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]June[/TD]
[TD]8-Jun-2018[/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD]6,000[/TD]
[TD]9,000[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]July[/TD]
[TD]5-Jul-2018[/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD]6,100[/TD]
[TD]9,100[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]July[/TD]
[TD]5-Jul-2018[/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD]6,200[/TD]
[TD]9,200[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]July[/TD]
[TD]7-Jul-2018[/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD]6,300[/TD]
[TD]9,300[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]July[/TD]
[TD]8-Jul-2018[/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD]6,400[/TD]
[TD]9,400[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]July[/TD]
[TD]9-Jul-2018[/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD]6,500[/TD]
[TD]9,500[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]July[/TD]
[TD]9-Jul-2018[/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD]6,600[/TD]
[TD]9,600[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]July[/TD]
[TD]9-Jul-2018[/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD]6,700[/TD]
[TD]9,700[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]August[/TD]
[TD]3-Aug-2018[/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD]6,800[/TD]
[TD]9,800[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]August[/TD]
[TD]3-Aug-2018[/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD]6,900[/TD]
[TD]9,900[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]August[/TD]
[TD]3-Aug-2018[/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD]7,000[/TD]
[TD]10,000[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]August[/TD]
[TD]3-Aug-2018[/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD]7,100[/TD]
[TD]10,100[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]August[/TD]
[TD]7-Aug-2018[/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD]7,200[/TD]
[TD]10,200[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]August[/TD]
[TD]7-Aug-2018[/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD]7,300[/TD]
[TD]10,300[/TD]
[TD] [/TD]
[/TR]
</tbody>[/TABLE]



Hello above data filtering by below code from first column,

Code:
Private Sub ComboBox2_Change()



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


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


Exit Sub
End If
a = Worksheets("list").Range("a1").Resize(Worksheets("list").Range("a" & Rows.Count).End(xlUp).Row, 15).Value
For i = 1 To UBound(a, 1)
If a(i, 1) = .Text Then
n = n + 1: ReDim Preserve b(1 To 15, 1 To n)
For ii = 1 To UBound(a, 2)
b(ii, n) = a(i, ii)
Next
b(2, n) = Format$(a(i, 2), "dd-mmm-yyyy")
'b(5, n) = Format$(a(i, 5), "h:mm")
End If
Next
End With
With ListBox1
.ColumnCount = 15
.ColumnWidths = "0;60;60;120;120;0;0;0;0;0;0;0;100;100;0"
.Column = b
End With
End Sub


Is it possible to filter those datas into the listbox as given table below?
Column M and Column N values will sum base on column A data.
If I select June the list must populate as given table.
Many Thanks





[TABLE="width: 1576"]
<colgroup><col><col><col><col span="2"><col><col span="2"><col span="2"><col><col span="3"><col></colgroup><tbody>[TR]
[TD]MONTH[/TD]
[TD]DATE[/TD]
[TD]CUSTOMER ID#[/TD]
[TD]FIRST NAME[/TD]
[TD]LAST NAME[/TD]
[TD]DATA[/TD]
[TD]DATA[/TD]
[TD]DATA[/TD]
[TD]DATA[/TD]
[TD]DATA[/TD]
[TD]DATA[/TD]
[TD]DATA[/TD]
[TD]POINTS[/TD]
[TD]POINTS[/TD]
[TD]DATA[/TD]
[/TR]
[TR]
[TD]June[/TD]
[TD]7-Jun-2018[/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD]26,000[/TD]
[TD]41,000[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]June[/TD]
[TD]8-Jun-2018[/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD]34,500[/TD]
[TD]52,500[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]July[/TD]
[TD]5-Jul-2018[/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD]12,300[/TD]
[TD]18,300[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]July[/TD]
[TD]7-Jul-2018[/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD]6,300[/TD]
[TD]9,300[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]July[/TD]
[TD]8-Jul-2018[/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD]6,400[/TD]
[TD]9,400[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]July[/TD]
[TD]9-Jul-2018[/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD]19,800[/TD]
[TD]28,800[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]August[/TD]
[TD]3-Aug-2018[/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD]27,800[/TD]
[TD]39,800[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]August[/TD]
[TD]7-Aug-2018[/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD]21,800[/TD]
[TD]20,500[/TD]
[TD] [/TD]
[/TR]
</tbody>[/TABLE]
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.

Forum statistics

Threads
1,223,893
Messages
6,175,249
Members
452,623
Latest member
Techenthusiast

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