Solved

# Sending data from List Box

Posted on 2012-03-22
192 Views
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
Question by:Seamus2626

LVL 85

Accepted Solution

Rory Archibald earned 500 total points
ID: 37751772
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
``````
0

Author Closing Comment

ID: 37751892
Cheers Rory!
0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http:/Q_27311462.html), I created an alternative function to the Excel Concatenate() function that you might find useful.  I tested several solutions and share the results in this article as well as t…
How to quickly and accurately populate Word documents with Excel data, charts and images (including Automated Bookmark generation) David Miller (dlmille) Synopsis In this article you’ll learn how to use ExcelToWord! to copy data,charts, shapes …
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…