Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 94
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
listbox B conditional of input in Listbox A Kim K Excel Discussion (Misc queries) 1 October 31st 06 08:27 PM
How access a listbox on a worksheet AsIs Excel Programming 6 June 21st 04 03:43 AM
Multicolumn Listbox and ordinary listbox Ron_D Excel Programming 0 June 4th 04 08:56 PM
listbox.value not equal to listbox.list(listbox.listindex,0) ARB Excel Programming 0 October 22nd 03 12:46 AM
Is refreshing listbox rowsource in listbox click event possible? Jeremy Gollehon[_2_] Excel Programming 4 September 25th 03 06:45 PM


All times are GMT +1. The time now is 01:13 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"