Solved

Sending data from List Box

Posted on 2012-03-22
2
192 Views
Last Modified: 2012-03-22
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
Comment
Question by:Seamus2626
2 Comments
 
LVL 85

Accepted Solution

by:
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

Open in new window

0
 

Author Closing Comment

by:Seamus2626
ID: 37751892
Cheers Rory!
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

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…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question