PDA

View Full Version : Solved: Display records against Single Date



tqm1
05-31-2007, 09:54 PM
Dear Experts

Sheets(Weight") has 29 coloumn.
Range("E") contains DateS
In listbox, I want to insert data of columns("E","B","D","N","M") against given Date in textbox1.

Sheets("Weight") and userform with listbox is in attachment.

Please help

Bob Phillips
06-01-2007, 03:44 AM
Private Sub CommandButton1_Click()
Dim c As Range
Dim sDate As Date

sDate = CDate(Me.TextBox1.Value)
ListBox1.Clear
For Each c In Worksheets("weight").Range("E:E")

If c.Value = sDate Then
With ListBox1
.AddItem Worksheets("weight").Cells(c.Row, "E").Value
.List(.ListCount - 1, 1) = Worksheets("weight").Cells(c.Row, "B").Value
.List(.ListCount - 1, 2) = Worksheets("weight").Cells(c.Row, "D").Value
.List(.ListCount - 1, 3) = Worksheets("weight").Cells(c.Row, "N").Value
.List(.ListCount - 1, 4) = Worksheets("weight").Cells(c.Row, "M").Value
End With
End If
Next c

End Sub