Private Sub CommandButton1_Click()
Dim AL As Object: Set AL = CreateObject("System.Collections.ArrayList")
Dim LO As ListObject: Set LO = ActiveSheet.ListObjects("Table1")
Dim res As String: res = vbNullString
If Me.CheckBox1 Or Me.CheckBox2 Then
Application.ScreenUpdating = False
For i = 0 To Me.ListBox1.ListCount - 1
If Me.ListBox1.Selected(i) Then
If Not AL.contains(Me.ListBox1.List(i)) Then AL.Add Me.ListBox1.List(i)
End If
Next i
LO.Range.AutoFilter Field:=1, Criteria1:=Array(AL.toarray), Operator:=xlFilterValues
If Me.CheckBox1 Then res = Round(Evaluate("=Subtotal(1, " & LO.DataBodyRange.Columns(2).Address & ")"), 2) & " days"
If Me.CheckBox2 Then
If Len(res) > 0 Then res = res & vbLf
res = res & FormatCurrency(Evaluate("=Subtotal(1, " & LO.DataBodyRange.Columns(3).Address & ")"))
End If
MsgBox res
LO.Range.AutoFilter
Application.ScreenUpdating = True
Else
MsgBox "Nothing Selected"
End If
End Sub
Private Sub UserForm_Activate()
Dim LO As ListObject: Set LO = ActiveSheet.ListObjects("Table1")
Dim ar() As Variant: ar = LO.DataBodyRange.Value
Dim SD As Object: Set SD = CreateObject("Scripting.Dictionary")
For i = 1 To UBound(ar)
If Not SD.exists(ar(i, 1)) Then
SD.Add ar(i, 1), Nothing
Me.ListBox1.AddItem ar(i, 1)
End If
Next i
End Sub