1

I have a listbox that receives its values from cell references. My current code prints the chosen listbox values into cells: E2 and F2. My current code also overwrites the earlier chosen values if I run the macro several times. I want to change the code, so that when I run the macro several times, the chosen listbox values are written on the next empty cells. Current code:

Private Sub Commandbutton1_Click()
  
Dim i, k, Finito As Byte
  Finito = Listbox1.ListCount - 1
  i = 1
    For k = 0 To Finito
     If Listbox1.Selected(k) = True Then
         Cells(i + 1, 5) = Listbox1.List(k)
         Cells(i + 1, 6) = Listbox1.List(k, 1)
         i = i + 1
     End If
    Next k

End Sub
Aviato
  • 11
  • 1
  • 1
    Does this answer your question? [Error in finding last used cell in Excel with VBA](https://stackoverflow.com/questions/11169445/error-in-finding-last-used-cell-in-excel-with-vba) – Samuel Everson May 18 '21 at 12:32

0 Answers0