Can anybody help me with the following problem. I am trying to use VBA code to take the relevant selections made to populate a Listbox and to insert them back into a cell range within the worksheet. The code I have come up with so far is:
Private Sub cmdApply_Click()
Dim i As Integer
Dim j As Integer
Dim StartRow As Integer
Dim EndRow As Integer
Dim StartCol As Integer
Dim EndCol As Integer
Dim temp
StartRow = 7
EndRow = 28
StartCol = 19
EndCol = 19
For i = StartRow To EndRow
For j = StartCol To EndCol
For n = 0 To (lstSelectn.ListCount - 1)
If lstSelectn.List <> "" Then
temp = lstSelectn.List
Cells(i, j).Value = temp
End If
Next i
Next j
Next
End Sub
The code should take any data within the listbox and insert the individual text into subsequent cells across the specified cell range. However, I keep getting various error messages. I have tried permutations of the code which do run but which copy a single entry from the listbox across the whole cell range! Any help is much appreciated!
Private Sub cmdApply_Click()
Dim i As Integer
Dim j As Integer
Dim StartRow As Integer
Dim EndRow As Integer
Dim StartCol As Integer
Dim EndCol As Integer
Dim temp
StartRow = 7
EndRow = 28
StartCol = 19
EndCol = 19
For i = StartRow To EndRow
For j = StartCol To EndCol
For n = 0 To (lstSelectn.ListCount - 1)
If lstSelectn.List <> "" Then
temp = lstSelectn.List
Cells(i, j).Value = temp
End If
Next i
Next j
Next
End Sub
The code should take any data within the listbox and insert the individual text into subsequent cells across the specified cell range. However, I keep getting various error messages. I have tried permutations of the code which do run but which copy a single entry from the listbox across the whole cell range! Any help is much appreciated!