ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to add selected row into listbox? (https://www.excelbanter.com/excel-programming/348383-how-add-selected-row-into-listbox.html)

frankosun

How to add selected row into listbox?
 
Hi there,
i need a little bit help, i would like to know how to add selected row into
listbox?
Can anyone help me?

thanx

Leith Ross[_394_]

How to add selected row into listbox?
 

Hello frankosun,

There are 2 types of ListBoxes. The Forms ListBox and the Control
Toolbox ListBox. The Forms ListBox can display only a single column.
The Control Toobox ListBox can have multiple columns.

A1:A10 hold 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
B1:B10 hold 11, 12, 13, 14, 15, 16, 17 ,18, 19, 20

LOADING THE FORMS LISTBOX FROM A RANGE:

Dim MyArray ()
Dim MyRange As Range

Set MyRange = Worksheets("Sheet1").Range("A1:B10")
MyArray = MyRange

With Shapes("List Box 1").ControlFormat
..RemoveAllItems
For Each element In MyArray
..AddItem element
Next element
End With

LOADING THE CONTROL TOOLBOX LISTBOX FROM A RANGE:

Dim MyArray ()
Dim MyRange As Range

Set MyRange = Worksheets("Sheet1").Range("A1:B10")
MyArray = MyRange

ListBox1.List = MyArray

Because the range contains 2 columns the Control Toolbox ListBox will
also contain 2 columns. The ColumnCount property controls how many
columns will be visible in the ListBox.

Sincerely,
Leith Ross


--
Leith Ross
------------------------------------------------------------------------
Leith Ross's Profile: http://www.excelforum.com/member.php...o&userid=18465
View this thread: http://www.excelforum.com/showthread...hreadid=494382



All times are GMT +1. The time now is 05:43 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com