0

I have the following code that adds items from a list box starting in Cell A15, if I go back into the list box, it rewrites over the first items, how can I have it start on the first empty row starting at 15? Code below

Private Sub CommandButton3_Click()
   Dim lngLastRow As Long
   Dim lngCol As Long
   Dim lngIndex As Long
   For lngIndex = 0 To ListBox2.ListCount - 1
      Cells(lngIndex + 15, 1).Value = ListBox2.List(lngIndex)
   Next
   Unload Me
End Sub 

Having trouble figuring out the if thens

BigBen
  • 46,229
  • 7
  • 24
  • 40
dtur0331
  • 23
  • 2
  • 1
    See: https://stackoverflow.com/questions/11169445/find-last-used-cell-in-excel-vba on how to find the last row with a value. Then you can replace the `15` with that. – Scott Craner Jul 11 '23 at 19:05
  • I changed the code as follows, and i am getting an error with replacing the 15. Cells(lngIndex + LastRow, 1).Value = ListBox2.List(lngIndex) – dtur0331 Jul 12 '23 at 11:40

0 Answers0