tqm1
06-13-2007, 04:17 AM
Dear Experts
In Listbox, I get required data against given Date with following codes.
These codes work fine to data into Listbox.
But now I want copy required data to Sheet2.
Please modify codes
Private Sub CommandButton1_Click()
Dim c As Range
Dim sDate As Date
Dim ws As Worksheet
Set ws = Worksheets("weights")
sDate = Me.TextBox1.Value
ListBox1.CLEAR
For Each c In ws.Range("E:E")
If c.Value = sDate Then
With ListBox1
.AddItem Format(ws.Cells(c.Row, "E").Value, "dd-mm-yy")
.List(.ListCount - 1, 1) = ws.Cells(c.Row, "B").Value
.List(.ListCount - 1, 2) = ws.Cells(c.Row, "J").Value
.List(.ListCount - 1, 3) = ws.Cells(c.Row, "K").Value
.List(.ListCount - 1, 4) = ws.Cells(c.Row, "G").Value
.List(.ListCount - 1, 5) = ws.Cells(c.Row, "F").Value
.List(.ListCount - 1, 6) = ws.Cells(c.Row, "N").Value
.List(.ListCount - 1, 7) = ws.Cells(c.Row, "O").Value
.List(.ListCount - 1, 8) = ws.Cells(c.Row, "M").Value
.List(.ListCount - 1, 9) = ws.Cells(c.Row, "D").Value
End With
End If
Next c
End Sub
In Listbox, I get required data against given Date with following codes.
These codes work fine to data into Listbox.
But now I want copy required data to Sheet2.
Please modify codes
Private Sub CommandButton1_Click()
Dim c As Range
Dim sDate As Date
Dim ws As Worksheet
Set ws = Worksheets("weights")
sDate = Me.TextBox1.Value
ListBox1.CLEAR
For Each c In ws.Range("E:E")
If c.Value = sDate Then
With ListBox1
.AddItem Format(ws.Cells(c.Row, "E").Value, "dd-mm-yy")
.List(.ListCount - 1, 1) = ws.Cells(c.Row, "B").Value
.List(.ListCount - 1, 2) = ws.Cells(c.Row, "J").Value
.List(.ListCount - 1, 3) = ws.Cells(c.Row, "K").Value
.List(.ListCount - 1, 4) = ws.Cells(c.Row, "G").Value
.List(.ListCount - 1, 5) = ws.Cells(c.Row, "F").Value
.List(.ListCount - 1, 6) = ws.Cells(c.Row, "N").Value
.List(.ListCount - 1, 7) = ws.Cells(c.Row, "O").Value
.List(.ListCount - 1, 8) = ws.Cells(c.Row, "M").Value
.List(.ListCount - 1, 9) = ws.Cells(c.Row, "D").Value
End With
End If
Next c
End Sub