Selected Answer
Mussala
Your code doesn't work because ListBox1 isn't populated in the Initialize code.
Because I also used the Inititlize code to reset the filtered search (in your previous question), I suggest that your code is removed from Initialize and sits behind a new CommandButton1- now added with caption "Get today's values" (and shaded green) in the attached file. I've added code (in bold) to populate the other textboxes so that your filter on today's records can be done.
Revision 2, 29 August 2023:
In addtition, the revised file attached will show this month's Sales or Buy records (if chosen, Sales if not) and filter to show just values for today. The associated label are hidden (via Initialize) and only revealed if the "Get Today's value" button is pressed. If ComboBox1 is changed, they're hidden again.
Private Sub CommandButton1_Click()
' set for values (defaulting to Sales)
If Not (ComboBox1.Text = "SALES" Or ComboBox1.Text = "BUY") Then ComboBox1.Text = "SALES"
ComboBox2.Value = Month(Date)
Call LBoxPop
' filter for today's and sum
Dim MySum As Double
Dim r As Long
MySum = 0
With ListBox1
For r = .ListCount - 1 To 1 Step -1
' if it's today's date
If CDate(.List(r, 1)) = Date Then
' then add to sum
MySum = MySum + .List(r, 9)
Else
' else remove from list
.RemoveItem r
End If
Next r
End With
TextBox2.Value = Format(MySum, "#,##0.00")
' reveal textbox2 and label
TextBox2.Visible = True
Label5.Visible = True
End Sub
Note that rather than compare strings, it now converts the cell value to a date for comparison with Date and also loops backwards removing items which aren't today. The attached file now includes a item with today's date (shaded yellow) in both Sales abd Buy tabs.
Just click that button on the UserForm in the attached revised file.
Hope this helps.