Why does my code not work? It always writes in row A
The code in green works fine.
Private Sub CommandButton100_Click()
Dim lItem As Long
Dim IRange As Integer
For lItem = 0 To ListBox1.ListCount - 1
ListBox1.ColumnCount = 2
With Worksheets("Sheet6")
.Cells(lItem + 5, 1) = ListBox1.List(lItem, 0)
.Cells(lItem + 5, 2) = ListBox1.List(lItem, 1)
End With
With Sheets("Histo")
Item = Worksheets("Histo").Cells(Rows.Count, 1).End(xlUp).Value
.Cells(lItem + 1, 1) = Date
.Cells(lItem + 1, 2) = ListBox1.List(lItem, 0)
.Cells(lItem + 1, 3) = ListBox1.List(lItem, 1)
End With
The code in green works fine.
Private Sub CommandButton100_Click()
Dim lItem As Long
Dim IRange As Integer
For lItem = 0 To ListBox1.ListCount - 1
ListBox1.ColumnCount = 2
With Worksheets("Sheet6")
.Cells(lItem + 5, 1) = ListBox1.List(lItem, 0)
.Cells(lItem + 5, 2) = ListBox1.List(lItem, 1)
End With
With Sheets("Histo")
Item = Worksheets("Histo").Cells(Rows.Count, 1).End(xlUp).Value
.Cells(lItem + 1, 1) = Date
.Cells(lItem + 1, 2) = ListBox1.List(lItem, 0)
.Cells(lItem + 1, 3) = ListBox1.List(lItem, 1)
End With