Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
How can i access a listbox?
Hello all.
I have a listbox on the worksheet (not on a userform). I set range input and linked cell with properties window. Q.: How can i access this listbox from workbook macro? For example determine selected item. Thanks. PS: Excel XP -- Message posted from http://www.ExcelForum.com |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
How can i access a listbox?
You didn't specify whether the listbox is MultiSelect or not, but the code
below should get you started. The code assumes that ListBox1 is on Sheet1. Troy Sub Test1() Dim lbx1 As MSForms.ListBox Dim ii As Integer '''Assumes that ListBox1 is on Sheet1. Set lbx1 = Sheet1.ListBox1 If lbx1.MultiSelect = fmMultiSelectSingle Then MsgBox "Value = " & lbx1.Value & _ " : Index = " & lbx1.ListIndex Else For ii = 0 To lbx1.ListCount - 1 MsgBox lbx1.List(ii) & _ " : Index = " & ii & _ " : Selected = " & lbx1.Selected(ii) Next ii End If End Sub "AsIs " wrote in message ... Hello all. I have a listbox on the worksheet (not on a userform). I set range input and linked cell with properties window. Q.: How can i access this listbox from workbook macro? For example, determine selected item. Thanks. PS: Excel XP. --- Message posted from http://www.ExcelForum.com/ |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
listbox B conditional of input in Listbox A | Excel Discussion (Misc queries) | |||
How access a listbox on a worksheet | Excel Programming | |||
Multicolumn Listbox and ordinary listbox | Excel Programming | |||
listbox.value not equal to listbox.list(listbox.listindex,0) | Excel Programming | |||
Is refreshing listbox rowsource in listbox click event possible? | Excel Programming |