Private Sub CommandButton9_Click()
Dim J As Long, WS As Worksheet
Set WS = Worksheets("PROCESSEDPV")
'Dim varTotal As Integer
'Dim varRow As Integer
'Dim x As Integer
'x = ListBox1.ListCount
'On Error Resume Next
Me.ListBox1.AddItem
For a = 1 To 10
Me.ListBox1.List(0, a - 1) = Sheet1.Cells(1, a)
Next a
Me.ListBox1.Selected(0) = True
If TextBox10.Value = "" Or TextBox11.Value = "" Then
MsgBox "Please Choose Date", vbCritical, ""
Exit Sub
End If
If CDate(TextBox10.Value) > CDate(TextBox11.Value) Then
MsgBox "The Start Date Can Not Be Bigger Than The End Date.", vbCritical, ""
Exit Sub
End If
ListBox1.Clear
For J = 2 To Worksheets("PROCESSEDPV").Range("J" & Rows.Count).End(xlUp).Row
If CDate(WS.Cells(J, "J").Value) >= CDate(TextBox10.Value) And CDate(WS.Cells(J, "J").Value) <= CDate(TextBox11.Value) Then
With ListBox1
.AddItem WS.Cells(J, 1).Value
.List(.ListCount - 1, 1) = WS.Cells(J, 2).Value
.List(.ListCount - 1, 2) = WS.Cells(J, 3).Value
.List(.ListCount - 1, 3) = WS.Cells(J, 4).Value
.List(.ListCount - 1, 4) = WS.Cells(J, 5).Value
.List(.ListCount - 1, 5) = WS.Cells(J, 6).Value
.List(.ListCount - 1, 6) = WS.Cells(J, 7).Value
.List(.ListCount - 1, 7) = VBA.Format(WS.Cells(J, 8).Value, "#,##0.00")
.List(.ListCount - 1, 8) = WS.Cells(J, 9).Value
.List(.ListCount - 1, 9) = WS.Cells(J, 10).Value
End With
End If
Next J
J = Empty
'For varRow = 0 To ListBox1.ListCount - 1
'varTotal = Val(varTotal) + Val(ListBox1.Column(7, varRow))
'Next
'End With
'TextBox13 = VBA.Format(varTotal, "#,##00.00")
Label21 = ListBox1.ListCount
End Sub
Kind regards
Leo
Bookmarks