My goal is to use a userform listbox and command button to populate data in cells one by one within a specified range of cells. Courtesy of this ExcelVbals YouTube video, I have come up with the following code for my command button:
Private Sub CommandButton1_Click() myVar = "" For x = 0 To Me.lbxTitle.ListCount - 1 If Me.lbxTitle.Selected(x) Then If myVar = "" Then myVar = Me.lbxTitle.List(x, 0) Else myVar = myVar & " " & Me.lbxTitle.List(x, 0) End If End If Next x ThisWorkbook.Sheets("sheet1").Range("C7:C73") = myVar End Sub Private Sub lbxTitle_Click() End Sub
The problem is this code populates the entire “C7:C73” range, when I want to populate cells individually within that range using distinct values selected from the listbox.
Thank you for your time and consideration!