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