Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 203
  • Last Modified:

Sending data from List Box

Hi, i have a piece of code that sends data from a list box in one excel workbook to a sheet in another excel workbook.

The code is below

The problem is it sends all entries from the listbox whereas i only want it to send the item that has been selected by the user

How can i achieve this?

Thanks
Seamus


Private Sub SendingData_Click()
Dim NextCell As Range
Dim arrList



     Set NextCell = Workbooks("Match.xls").Worksheets("Mapping Table").Range("B" & Rows.Count).End(xlUp).Offset(1)

      arrList = ListBox2.List

     NextCell.Resize(UBound(arrList)).value = arrList
End Sub
0
Seamus2626
Asked:
Seamus2626
1 Solution
 
Rory ArchibaldCommented:
If it's a single select listbox, then it's just:

Private Sub SendingData_Click()
Dim NextCell As Range
Dim arrList



     Set NextCell = Workbooks("Match.xls").Worksheets("Mapping Table").Range("B" & Rows.Count).End(xlUp).Offset(1)

     NextCell.value = Listbox2.Value
End Sub

Open in new window

0
 
Seamus2626Author Commented:
Cheers Rory!
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now