Hi
I need showing about 11 columns in listbox on userform based on fill date textbox1 is from date , textbox2 is to date and match with column A (DATE)for sheet1
I need showing about 11 columns in listbox on userform based on fill date textbox1 is from date , textbox2 is to date and match with column A (DATE)for sheet1
VBA Code:
Private Sub TextBox1_AfterUpdate()
On Error Resume Next
Me.TextBox1.Value = Format(TextBox1.Value, "mm/dd/yyyy")
End Sub
Private Sub TextBox2_AfterUpdate()
Dim i As Long
On Error Resume Next
Me.TextBox2 = Format(Me.TextBox2, "mm/dd/yyyy")
Me.ListBox1.Clear
For i = 2 To Application.WorksheetFunction.CountA(sheet1.Range("a:a"))
If sheet1.Cells(i, 1).Value >= CDate(Me.TextBox1.Text) And _
sheet1.Cells(i, 1).Value <= CDate(Me.TextBox2.Text) Then
Me.ListBox1.AddItem sheet1.Cells(i, 1).Value
Me.ListBox1.List(ListBox1.ListCount - 1, 1) = sheet1.Cells(i, 2).Value
Me.ListBox1.List(ListBox1.ListCount - 1, 2) = sheet1.Cells(i, 3).Value
Me.ListBox1.List(ListBox1.ListCount - 1, 3) = sheet1.Cells(i, 4).Value
Me.ListBox1.List(ListBox1.ListCount - 1, 4) = sheet1.Cells(i, 5).Value
Me.ListBox1.List(ListBox1.ListCount - 1, 5) = sheet1.Cells(i, 6).Value
Me.ListBox1.List(ListBox1.ListCount - 1, 6) = sheet1.Cells(i, 7).Value
Me.ListBox1.List(ListBox1.ListCount - 1, 7) = sheet1.Cells(i, 8).Value
Me.ListBox1.List(ListBox1.ListCount - 1, 8) = sheet1.Cells(i, 9).Value
Me.ListBox1.List(ListBox1.ListCount - 1, 9) = sheet1.Cells(i, 10).Value
Me.ListBox1.List(ListBox1.ListCount - 1, 10) = sheet1.Cells(i, 11).Value
End If
Next i
End Sub