I will try and explain this as best as I can...
From a 2 column Listbox on a userform, I need to select a row and copy that row into a spreadsheet (columns C and D, from row 5 up to last row).
I have attached some images so you have an idea of what I am trying to do.
The code below will only change the last row... So C7 and D7. I need it to change the whole range up to last row.
From a 2 column Listbox on a userform, I need to select a row and copy that row into a spreadsheet (columns C and D, from row 5 up to last row).
I have attached some images so you have an idea of what I am trying to do.
The code below will only change the last row... So C7 and D7. I need it to change the whole range up to last row.
Code:
Sub UpdateVRN()
Dim ws As Worksheet
Dim i As Long
Dim lRow As Long
Set ws = ThisWorkbook.Sheets("Data")
lRow = ws.Range("B" & ws.Rows.Count).End(xlUp).row
For i = 0 To frmChangeVRN.lstVRN.ListCount - 1
If frmChangeVRN.lstVRN.Selected(i) Then
ws.Cells(lRow, 4) = frmChangeVRN.lstVRN.List(i, 0)
ws.Cells(lRow, 3) = frmChangeVRN.lstVRN.List(i, 1)
End If
Next i
End Sub